Hi Steffen

TAP as you probably know is a line-oriented protocol whose main purpose it to 
let test scripts communicate pass/fail results to a test harness.  Functions 
like 'ok' or 'pass' or 'fail' in Test::More print lines that tell the harness 
whether a test passed or failed. 

The main TAP site is http://testanything.org/.  The TAP specification is at 
http://podwiki.hexten.net/TAP/TAP.html?page=TAP

I learned about TAP pragmas by reading the TAP CPAN documentation and code, 
esp. TAP::Parser , 
http://search.cpan.org/~ovid/Test-Harness-3.28/lib/TAP/Parser.pm#pragmas

To make it work you have to tell the TAP harness that you're using TAP version 
13, whose specification is at 
http://podwiki.hexten.net/TAP/TAP13.html?page=TAP13

You do this from a test script  by printing this line  
        TAP version 13

The format of a pragma is       pragma +/-<whatever>, eg,
        pragma +strict

The + or - is mandatory!

To process a non-standard pragma, you have to customize some aspect of the test 
harness.  I did this by creating a subclass of Module::Build which I needed for 
other purposes anyway.  The subclass is in the Data::Babel 1.12 distribution, 
file t/Build.pm.  You also have to tell the main Build driver to use the 
subclass.  This is in Build.PL; the relevant few lines of code are near the top

        use lib qw(t);
        use t::Build;                   # my Module::Build subclass
        my $class='t::Build';

followed a few lines later by 

        my $builder = $class->new
        ....

I hope this helps.  Feel free to ask for further clarification as necessary.  
I'm glad to help. 

Best,
Nat

On Aug 6, 2013, at 3:51 AM, Steffen Schwigon wrote:

> "Nathan (Nat) Goodman" <ngood...@systemsbiology.org> writes:
>> 3) What I ended up doing with Data::Babel (and will do with
>> Class:AutoDB soon) is to move the check for MySQL into a test script
>> that runs first. If the script detects that MySQL is unavailable, it
>> reports this to the test driver using the pragma capability of TAP
>> version 13, and a slightly customized version of
>> Build::run_tap_harness (included in my distribution) breaks out of the
>> test suite when it sees this pragma, reporting PASS as the outcome.
> 
> Can you please elaborate more on the details of your pragma solution. 
> 
> I never saw a TAP pragma in real world[1] and would love to understand
> it - without reading into your code, sorry for that laziness... :-)
> 
> Kind regards,
> Steffen
> 
> Footnotes: 
> [1]  except that I support highlighting it in Emacs TAP mode
> -- 
> Steffen Schwigon <s...@renormalist.net>

Reply via email to