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
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”.)