--- Julien Beasley <[EMAIL PROTECTED]> wrote:
> I'm trying to get my project to move to TAP -- we have some perl test
> files
> and some C++ test files. Let's say I have 2 files: test.pl, and
> test.exe,
> the former is a perl program and the latter is a compiled program
> that
> outputs TAP.
>
> How do I use TAPx::Harness to run them both? I'm not really sure how
> to use
> the 'exec' switch for a program that doesn't require an interpreter
> :)
I need to write a tutorial on how to do this, to be honest. It's one of
the more advanced features, but it's pretty easy.
First, here's a tiny C++ program with a deliberately failing test:
#include <iostream>
int main()
{
std::cout << "1..3\n";
std::cout << "ok 1 whoopee!\n";
std::cout << "not ok 2 :(\n";
std::cout << "not ok 3 # TODO some test\n";
}
Compile it and move it to the test directory:
g++ tap.cpp -otap.exe && mv tap.exe t/
Also in that test directory is this Perl program:
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 2;
ok 1, 'first test';
ok 2, 'second test';
To run the C++, you have create a "driver script" (don't forget to make
it executable):
$ cat bin/run.pl
#!/usr/bin/perl
use strict;
use warnings;
my $prog = shift;
unless ( -e $prog && -x _ ) {
die "Cannot find or execute ($prog)";
}
exec $prog;
This script doesn't need to be elaborate, it just needs to spit out TAP
(see the TAPx::Parser examples/ directory for an example which spits
out TAP for URLs)
Then you need an 'execrc' file. This is written in YAML:
code $ cat my_execrc
---
tests:
# this is the default for all files
-
- /usr/bin/perl
- -wT
- *
# Here's how we run the c++
-
- bin/run.pl
- t/tap.exe
And here's how to run your Perl and C++ tests at the same time:
$ runtests --execrc my_execrc t/*
t/perl.......ok
t/tap........ Failed 1/3 subtests
Test Summary Report
-------------------
t/tap.exe (Wstat: 0 Tests: 3 Failed: 1)
Failed tests: 2
Files=2, Tests=5, 0 wallclock secs ( 0.04 cusr + 0.00 csys = 0.04
CPU)
Note that the format of the execrc file is likely to change in the
future. You also probably want the latest development version of
TAPx::Parser on the CPAN.
Cheers,
Ovid
--
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/