views:

82

answers:

3

I have a Test::More test script for a module we have made. When running the test script by itself, it works just as expected. Since there are several tests we need to run, I made a Test::Harness file that run all scripts. However, when executing from the Test::Harness runtests the script returns errors.

During debugging I tried to run the script by using backtics and that worked. So the runtest command caused the errors.

The code of the harness is pretty straightforward:

(perl) -w
use strict;
use warnings;
use Test::Harness;

my @tests = ('test1.pl', 'test2.pl', 'test3.pl');
runtests(@tests);

The errors originate from a cpan module we use, Pod::HtmlEasy.

The solution I'm hoping for is for a way to run the Test::Harness without getting the errors.

The output from the test:

test1..........False [] range "\w-" in regex; marked by  line 20.
Use of uninitialized value in string ne at /app/perl/lib/Pod/HtmlEasy/Parser.pm line 422,  line 20.
Use of uninitialized value in string ne at /app/perl/lib/Pod/HtmlEasy/Parser.pm line 363,  line 22.
False [] range "\w-" in regex; marked by  line 22.
Use of uninitialized value in string ne at /app/perl/lib/Pod/HtmlEasy/Parser.pm line 488,  line 24.
Use of uninitialized value in string ne at /app/perl/lib/Pod/HtmlEasy/Parser.pm line 363,  line 26.
close() on unopened filehandle PODIN at /app/perl/lib/Pod/HtmlEasy.pm line 248.
Use of uninitialized value in concatenation (.) or string at /app/perl/lib/Pod/HtmlEasy.pm line 318.
(...)
Use of uninitialized value in concatenation (.) or string at /app/perl/lib/Pod/HtmlEasy.pm line 396.
test1..........ok 2/3close() on unopened filehandle PODIN at /app/perl/lib/Pod/HtmlEasy.pm line 248.
Use of uninitialized value in concatenation (.) or string at /app/perl/lib/Pod/HtmlEasy.pm line 318.
(...)
Use of uninitialized value in concatenation (.) or string at /app/perl/lib/Pod/HtmlEasy.pm line 396.
test1..........ok                                                      
+2  A: 

Why are you creating your own testing script? Just put your module into the standard distribution setup and run it from the build script. Additionally, you can just use prove to do what you are already doing.

brian d foy
+4  A: 

Why not just let Test::Harness construct a test environment on the fly, from the command line?

prove test*.pl

Or if you keep your tests in the t/ directory as is standard:

prove -r t/
Ether
Thanks! Prove worked fine. At this time the test infrastructure relies on a test::harness file that lists all testscripts, but we are planning a do-over so i'll suggest this.
Fredrik
It sounds like you want my Test::Manifest if you want to list the tests to run.
brian d foy
+2  A: 

The output you pasted shows your tests passing. The messages that are output are warnings. If you don't get the warnings when you run perl test1.pl, it's because you (or the module you're using) didn't enable warnings. Apparently Test::Harness invokes perl with the -w flags, and you get the warnings, since -w enables warnings globally. ("use warnings" only enables them in the lexical scope that said "use warnings".)

jrockway
Nice, I missed that one. Adding the -w to the test script gave the exact same logs. So atleast this means the test::harness doesnt introduce some fault.
Fredrik