Subject: | Oneshot tests fail when temporary file names contain unusual characters |
While attempting to install IO-Compress 2.034 under Perl 5.12.3 on Mac
OS 10.5.8 (Leopard), I encountered the following errors during the tests:
t/105oneshot-bzip2.t ............ 1/987 Nested quantifiers in regex;
marked by <-- HERE in m/input file
'/var/folders/bH/bHwrvbIq2RWUI++1Yuez9+++ <-- HERE +TI/-Tmp-/uScg7Ucp5L'
is a directory/ at t/Test/Builder.pm line 699.
# Looks like you planned 987 tests but only ran 10.
# Looks like your test died just after 10.
t/105oneshot-bzip2.t ............ Dubious, test returned 255 (wstat
65280, 0xff00)
Failed 977/987 subtests
t/105oneshot-deflate.t .......... 1/987 Nested quantifiers in regex;
marked by <-- HERE in m/input file
'/var/folders/bH/bHwrvbIq2RWUI++1Yuez9+++ <-- HERE +TI/-Tmp-/qY_OXV7OQd'
is a directory/ at t/Test/Builder.pm line 699.
# Looks like you planned 987 tests but only ran 10.
# Looks like your test died just after 10.
t/105oneshot-deflate.t .......... Dubious, test returned 255 (wstat
65280, 0xff00)
Failed 977/987 subtests
t/105oneshot-gzip-only.t ........ ok
t/105oneshot-gzip.t ............. 1/987 Nested quantifiers in regex;
marked by <-- HERE in m/input file
'/var/folders/bH/bHwrvbIq2RWUI++1Yuez9+++ <-- HERE +TI/-Tmp-/D5AoYZRo9Y'
is a directory/ at t/Test/Builder.pm line 699.
# Looks like you planned 987 tests but only ran 10.
# Looks like your test died just after 10.
t/105oneshot-gzip.t ............. Dubious, test returned 255 (wstat
65280, 0xff00)
Failed 977/987 subtests
t/105oneshot-rawdeflate.t ....... 1/987 Nested quantifiers in regex;
marked by <-- HERE in m/input file
'/var/folders/bH/bHwrvbIq2RWUI++1Yuez9+++ <-- HERE +TI/-Tmp-/VepuaDzQxL'
is a directory/ at t/Test/Builder.pm line 699.
# Looks like you planned 987 tests but only ran 10.
# Looks like your test died just after 10.
t/105oneshot-rawdeflate.t ....... Dubious, test returned 255 (wstat
65280, 0xff00)
Failed 977/987 subtests
t/105oneshot-zip-bzip2-only.t ... ok
t/105oneshot-zip-only.t ......... ok
t/105oneshot-zip.t .............. 1/987 Nested quantifiers in regex;
marked by <-- HERE in m/input file
'/var/folders/bH/bHwrvbIq2RWUI++1Yuez9+++ <-- HERE +TI/-Tmp-/b562S5Raxq'
is a directory/ at t/Test/Builder.pm line 699.
# Looks like you planned 987 tests but only ran 10.
# Looks like your test died just after 10.
t/105oneshot-zip.t .............. Dubious, test returned 255 (wstat
65280, 0xff00)
Failed 977/987 subtests
The issue appears to be that when t/compress/oneshot.pl was modified to
let File::Temp generate the file and directory names, it did not take
into account the possibility that that the generated names might contain
things that would be interpreted by the Perl regular expression engine
as meta-characters.
Applying the changes given in the attached oneshot.diff file to
t/compress/oneshot.pl causes the tests to run cleanly on my OS X system,
and also on Ubuntu 11.4 Natty Narwhal.
Subject: | oneshot.diff |
--- t/compress/oneshot.old 2011-05-06 23:08:53.000000000 -0400
+++ t/compress/oneshot.pl 2011-05-06 23:09:16.000000000 -0400
@@ -84,12 +84,12 @@
$a = $Func->("$dir", \$x) ;
is $a, undef, " $TopType returned undef";
- like $$Error, "/input file '$dir' is a directory/",
+ like $$Error, qr{input file '\Q$dir\E' is a directory},
' Input filename is a directory';
$a = $Func->(\$x, "$dir") ;
is $a, undef, " $TopType returned undef";
- like $$Error, "/output file '$dir' is a directory/",
+ like $$Error, qr{output file '\Q$dir\E' is a directory},
' Output filename is a directory';
}
@@ -899,7 +899,7 @@
foreach (@files) { writeFile($_, "abc $_") }
my @expected = map { "abc $_" } @files ;
- my @outFiles = map { s/$tmpDir1/$tmpDir2/; $_ } @files ;
+ my @outFiles = map { s/\Q$tmpDir1/$tmpDir2/; $_ } @files ;
{
title "$TopType - From FileGlob to FileGlob files [@$files]" ;
@@ -1406,7 +1406,7 @@
foreach (@files) { writeFile($_, compressBuffer($UncompressClass, "abc $_")) }
my @expected = map { "abc $_" } @files ;
- my @outFiles = map { s/$tmpDir1/$tmpDir2/; $_ } @files ;
+ my @outFiles = map { s/\Q$tmpDir1/$tmpDir2/; $_ } @files ;
{
title "$TopType - From FileGlob to FileGlob" ;