Subject: | Reading from close filehandle in test |
'make test' produces the following:
/usr/bin/perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0,
'blib/lib', 'blib/arch')" t/*.t
t/00pod...................ok
t/01SelfLoader............readline() on closed filehandle DATA at
t/01SelfLoader.t line 181.
ok
t/02SelfLoader-buggy......ok
All tests successful.
Files=3, Tests=22, 1 wallclock secs ( 0.03 usr 0.00 sys + 0.34 cusr
0.11 csys = 0.48 CPU)
Result: PASS
However, when I run: perl -Mblib t/01_SelfLoader.t that warning does
not appear.
This occurs with both 5.8.8 maint and 5.10.0.
The attached patch seems to correct this problem.
Subject: | sl.patch |
--- t/01SelfLoader.t.orig 2008-01-17 09:04:35.532501800 -0500
+++ t/01SelfLoader.t 2008-01-17 09:04:41.798848600 -0500
@@ -178,12 +178,15 @@
}
# Try to read from the data file handle
-my $foodata = <Foo::DATA>;
-close Foo::DATA;
-if (defined $foodata) {
- print "not ok 18 # $foodata\n";
-} else {
- print "ok 18\n";
+{
+ $SIG{__WARN__} = sub { my $warn = shift; };
+ my $foodata = <Foo::DATA>;
+ close Foo::DATA;
+ if (defined $foodata) {
+ print "not ok 18 # $foodata\n";
+ } else {
+ print "ok 18\n";
+ }
}
# Check that __END__ DATA is honoured