Skip Menu |

This queue is for tickets about the Test-Harness CPAN distribution.

Report information
The Basics
Id: 8753
Status: resolved
Priority: 0/
Queue: Test-Harness

People
Owner: andy [...] hexten.net
Requestors: NIKC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Test::Harness should run executable .t files directly
$Test::Harness::VERSION = 2.42 When Test::Harness goes to run a .t file, it executes it through $^X, irrespective of whether or not the .t file is executable. This breaks things if your .t file is directly executable object code -- e.g., if the test is compiled C code. At the moment, it's necessary to create a wrapper shim that does something like (assuming that the compiled code is <foo>, and the test is <foo>.t: --- #!/bin/sh cd `dirname $0` exec `basename $0 .t` --- While this works, it's not very elegant.
This won't work because the tests will likely rely on libraries that haven't been installed, as most Perl tests do. Consider the case of testing a shared library. You have some tests which are compiled C code. You want them to link against the just built shared libraries. Test::Harness has to know how to do this. It can't just blindly run the test executables. There's also a less compelling backwards compatibility argument. I'm sure lots of folks out there have normal Perl .t tests set +x without even thinking about it.
[guest - Mon Dec 6 10:37:51 2004]: Show quoted text
> When Test::Harness goes to run a .t file, it executes it through $^X, > irrespective of whether or not the .t file is executable.
Discussion with petdance on IM suggests that a '-x' flag for prove(1) (for 'executable test') is appropriate; along with the necessary changes to ::runtests(), obviously. N
From: adamk [...] cpan.org
[MSCHWERN - Mon Dec 6 14:51:50 2004]: Show quoted text
> This won't work because the tests will likely rely on libraries that > haven't been installed, as most Perl tests do. > > Consider the case of testing a shared library. You have some tests > which are compiled C code. You want them to link against the just built > shared libraries. Test::Harness has to know how to do this. It can't > just blindly run the test executables. > > There's also a less compelling backwards compatibility argument. I'm > sure lots of folks out there have normal Perl .t tests set +x without > even thinking about it.
Indeed. What springs to mind is that what he really should be doing is using the .t file (run with whatever Perl) to "set up" for the "real" test in some other file that isn't a .t, and exec over to it. Which would be a solution you could do using a Test:: module if there are specific types of ways to launch the executable test.
Le Dim. Jan. 01 01:45:54 2006, guest a écrit : Show quoted text
> What springs to mind is that what he really should be doing is using the > .t file (run with whatever Perl) to "set up" for the "real" test in some > other file that isn't a .t, and exec over to it.
The point of this ticket is to be able to run with Test::Harness/prove any non-Perl tests that conforms to the TAP. For example, consider the following C program: -------8<-------8<-------8<-------8<-------- #include <stdio.h> int main(int argc, char *argv[]) { puts("1..1\n" "ok 1"); return 0; } -------8<-------8<-------8<-------8<-------- Or this shell program: -------8<-------8<-------8<-------8<-------- #!/bin/sh echo "1..1 ok 1" -------8<-------8<-------8<-------8<-------- They have both valid TAP output but they are currently not working with prove. There is no point in having a universal TAP output format defined if TAP tools are Perl specific. The LibTap library (http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap) is useless without a parsing/reporting tool.
Here is a workaround: define HARNESS_PERL to /usr/bin/env. (My version of prove, 1.04, doesn't support --perl) Example: $ cc -o tap.t tap.t.c $ HARNESS_PERL=/usr/bin/env prove tap.t
Check out Test::Harness 2.99 for a full range of execution options :)