Reputation: 10646
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
Upvotes: 1
Views: 516
Reputation: 42674
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".)
Upvotes: 2
Reputation: 53966
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/
Upvotes: 5
Reputation: 132802
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.
Upvotes: 3