i want to catch the TAP output of my scripts, to write it with some additional information into an openoffice document for my collegues, and as normal TAP-Output for me into the console. This has to be done inside(!) my script.
I'll guess TAP::Parser is the way i should go, right? I don't know how, and i cant find an simple example. If i got a script like:
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 2;
is( 1 + 1, 2, "one plus one is two" );
#missing code to capture the result of the test above
is( 1 + 1, 11, "one plus one is more than two" );
#missing code to capture the result of the test above
How can i get the results of each test? To create a openoffice document is not the problem.
Is TAP::Parser the right way to do what i want?
Thx
roli
You could write a plugin for App::Prove. A good reference/starting point is the Test::Pretty.
One simple way to capture the output is with the
--archive
flag to prove. This will save the test suite output in a tarball along with a summary of the results. You should also use the--merge
flag so STDERR is captured.Once you have that you can read it back in at your leisure, reparse it with TAP::Parser and do what you like with it.
If for some reason you can't/won't use prove, you can insert capture code into your script. I would HIGHLY RECOMMEND AGAINST THIS as you have to do it for every test script, it must be hard coded into the test which makes them less useful for normal testing (ie. running the test via prove or Test::Harness (which prove is just a wrapper around)). You also have to do some fancy footwork to make sure you capture the complete output of the test, any warnings going to STDERR or STDOUT, not just the test output.
So before I explain that, since you're running the test program by hand (which you shouldn't be) here's how you do it using the bash shell.
If that works for you, use that. It's not worth getting into hard coding it into the script.
You still have to process test.out using something like the TAP::Harness script above to get meaning out of it, but that will capture the complete output of the program. You can do this in one step, again with shell redirection.
Where tap2oo is your program which translates TAP to an Open Office document.