Another option is to use IPC::System::Simple.
The driver script is a neat idea, I used this variation for testing my
harness wrapped around my Utils C library
Say I had C code in a Utils library, one source file which might have
this code
Utils.c
/**
* internal function
*/
static int hexChar2Int (unsigned char ch) {
if (ch = '0' ch = '9') return ch - '0';
if (ch = 'A' ch = 'F') return ch - 'A' + 10;
return -1;
}
The test harness might look like this
Test_Utils.c
#include tap.h
#include Utils.c
isInt(hexChar2Int('0'), 0);
isInt(hexChar2Int('Z'), -1);
And the perl driver could look like this
Test_Utils.t
use IPC::System::Simple;
...
run('test_Utils');
or
run('test_Utils', @args);
Note how the function we're testing is declared static, but we include
the C file in the harness - this is a neat way to get at the internal
functions and state variables in C code, if your testing down at that
level.
IPC::System::Simple give me finer grained control over testing return
codes from calls to run various harnesses
As with Ovid's code I options as to how I want to run this.
perl -MTest::Harness -e 'runtests(qw(test_Utils.t))'
prove test_Utils.t
make test
L
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Friday, 9 March 2007 11:19 PM
To: [EMAIL PROTECTED]; perl-qa@perl.org
Subject: Re: run C++ TAP output? (even easier)
If you want things to be *really* easy to run test suites in multiple
languages, do this.
First, make sure that all test programs are executable. Then use this
driver program:
$ 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;
Then 'find' all executable files and use the '--exec' option with
runtests to execute all of them with the 'bin/run.pl' program:
$ find t/ -perm /u+x -type f | xargs runtests --exec bin/run.pl
t/tap Failed 1/3 subtests
t/perl...ok
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)
Cheers,
Ovid
--
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/
**
IMPORTANT
The contents of this e-mail and its attachments are confidential and intended
solely for the use of the individual or entity to whom they are addressed. If
you received this e-mail in error, please notify the HPA Postmaster, [EMAIL
PROTECTED],
then delete the e-mail.
This footnote also confirms that this e-mail message has been swept for the
presence of computer viruses by Ironport. Before opening or using any
attachments, check them for viruses and defects.
Our liability is limited to resupplying any affected attachments.
HPA collects personal information to provide and market our services. For more
information about use, disclosure and access see our Privacy Policy at
www.hpa.com.au
**