Subject: | Null byte in __DATA__ in test scripts breaks prove |
I believe found an issue in Test::Harness causing it to fail when processing test files which
have a null byte in a __DATA__ segment. When a null byte is present, for some strange reason
the @INC fails to work. Here is how I created it.
File: lib/MyClass.pm
<<
package MyClass;
use strict;
use warnings;
1;
Show quoted text
>>
File: t/taptest.t
<<
use strict;
use MyClass;
__DATA__
asdf^@
ddd
Show quoted text>>
The ^@ shows where a null byte is present. When the command "prove -Ilib t/taptest.t" is
run, you get an error as follows (note that the command "perl -Ilib t/taptest.t" does not fail.
t/taptest.t .. Can't locate MyClass.pm in @INC (@INC contains:
/Users/stuart/perl/lib/site_perl/5.12.1/darwin-multi-2level
/Users/stuart/perl/lib/site_perl/5.12.1 /Users/stuart/perl/lib/5.12.1/darwin-multi-2level
/Users/stuart/perl/lib/5.12.1 .) at t/taptest.t line 2.
BEGIN failed--compilation aborted at t/taptest.t line 2.
t/taptest.t .. Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Test Summary Report
-------------------
t/taptest.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: No plan found in TAP output
Files=1, Tests=0, 0 wallclock secs ( 0.03 usr + 0.01 sys = 0.04 CPU)
Result: FAIL
This was based on a self-compiled 5.12.1 on OSX, but the problem has been traced from a
bad test in RTF::Parser, with many failures on different platforms. The problem only shows on
non-installed modules, and it appears that in some extremely strange fashion the null byte is
interfering with the @INC passed to the script.