stas 2004/09/27 20:37:27
Modified: t/response/TestModperl io_nested_with_closed_stds.pm
io_with_closed_stds.pm
Log:
solve the ' Unknown open() mode '<&' ' problem occuring under 5.6, by
using non my-$foo symbols as filehandles
Revision Changes Path
1.2 +11 -6 modperl-2.0/t/response/TestModperl/io_nested_with_closed_stds.pm
Index: io_nested_with_closed_stds.pm
===================================================================
RCS file:
/home/cvs/modperl-2.0/t/response/TestModperl/io_nested_with_closed_stds.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- io_nested_with_closed_stds.pm 17 Feb 2004 01:22:41 -0000 1.1
+++ io_nested_with_closed_stds.pm 28 Sep 2004 03:37:27 -0000 1.2
@@ -5,6 +5,10 @@
# internal_redirect(), which causes a nested override of already
# overriden STD streams
+# in this test we can't use my $foo as a filehandle, since perl 5.6
+# doesn't know how to dup via: 'open STDIN, "<&", $oldin'
+# so use the old FOO filehandle style
+
use strict;
use warnings FATAL => 'all';
@@ -13,6 +17,7 @@
use Apache::SubRequest ();
use Apache::Test;
+use Apache::TestUtil;
use Apache::Const -compile => 'OK';
@@ -36,17 +41,17 @@
# one of the STD streams is closed.
# but we must restore the STD streams so not to affect other
# tests.
- open my $oldin, "<&STDIN" or die "Can't dup STDIN: $!";
- open my $oldout, ">&STDOUT" or die "Can't dup STDOUT: $!";
+ open OLDIN, "<&STDIN" or die "Can't dup STDIN: $!";
+ open OLDOUT, ">&STDOUT" or die "Can't dup STDOUT: $!";
close STDIN;
close STDOUT;
$r->internal_redirect($redirect_uri);
- open STDIN, "<&", $oldin or die "Can't dup \$oldin: $!";
- open STDOUT, ">&", $oldout or die "Can't dup \$oldout: $!";
- close $oldin;
- close $oldout;
+ open STDIN, "<&OLDIN" or die "Can't dup OLDIN: $!";
+ open STDOUT, ">&OLDOUT" or die "Can't dup OLDOUT: $!";
+ close OLDIN;
+ close OLDOUT;
}
Apache::OK;
1.2 +12 -10 modperl-2.0/t/response/TestModperl/io_with_closed_stds.pm
Index: io_with_closed_stds.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestModperl/io_with_closed_stds.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- io_with_closed_stds.pm 17 Feb 2004 01:22:41 -0000 1.1
+++ io_with_closed_stds.pm 28 Sep 2004 03:37:27 -0000 1.2
@@ -3,6 +3,12 @@
# test that we can successfully override STD(IN|OUT) for
# 'perl-script', even if they are closed.
+# in this test we can't use my $foo as a filehandle, since perl 5.6
+# doesn't know how to dup via: 'open STDIN, "<&", $oldin'
+# so use the old FOO filehandle style, which is also global, so we
+# don't even need to pass it around (very bad code style, but I see no
+# better solution if we want to have this test run under perl 5.6)
+
use strict;
use warnings FATAL => 'all';
@@ -21,12 +27,10 @@
# we must close STDIN as well, due to a perl bug (5.8.0 - 5.8.3
# w/useperlio), which emits a warning if dup is called with
# one of the STD streams is closed.
- open my $oldin, "<&STDIN" or die "Can't dup STDIN: $!";
- open my $oldout, ">&STDOUT" or die "Can't dup STDOUT: $!";
+ open OLDIN, "<&STDIN" or die "Can't dup STDIN: $!";
+ open OLDOUT, ">&STDOUT" or die "Can't dup STDOUT: $!";
close STDIN;
close STDOUT;
- $r->pnotes(oldin => $oldin);
- $r->pnotes(oldout => $oldout);
Apache::OK;
}
@@ -45,12 +49,10 @@
my $r = shift;
# restore the STD(IN|OUT) streams so not to affect other tests.
- my $oldin = $r->pnotes('oldin');
- my $oldout = $r->pnotes('oldout');
- open STDIN, "<&", $oldin or die "Can't dup \$oldin: $!";
- open STDOUT, ">&", $oldout or die "Can't dup \$oldout: $!";
- close $oldin;
- close $oldout;
+ open STDIN, "<&OLDIN" or die "Can't dup OLDIN: $!";
+ open STDOUT, ">&OLDOUT" or die "Can't dup OLDOUT: $!";
+ close OLDIN;
+ close OLDOUT;
Apache::OK;
}