From 3fb41248088529e4dffd3e393588e067e2934fc0 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 3 Nov 2005 14:56:25 +0000 Subject: [PATCH] More core test cleanups. Mainly fixes to remove code that caused warnings, but there were a few bug fixes that were hidden by no using warnings. p4raw-id: //depot/perl@25973 --- t/io/nargv.t | 1 + t/io/openpid.t | 5 ++++- t/io/pipe.t | 1 + t/io/print.t | 1 + t/io/read.t | 1 + t/io/tell.t | 39 ++++++++++++++++++++++----------------- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/t/io/nargv.t b/t/io/nargv.t index fb13857..97ab639 100755 --- a/t/io/nargv.t +++ b/t/io/nargv.t @@ -44,6 +44,7 @@ sub show { } sub other { + no warnings 'once'; print STDOUT "# Calling other\n"; local *ARGV; local *ARGVOUT; diff --git a/t/io/openpid.t b/t/io/openpid.t index 23d75ef..449a268 100755 --- a/t/io/openpid.t +++ b/t/io/openpid.t @@ -45,7 +45,10 @@ $cmd4 = qq/$perl -e "print scalar <>;"/; # start the processes ok( $pid1 = open(FH1, "$cmd1 |"), 'first process started'); ok( $pid2 = open(FH2, "$cmd2 |"), ' second' ); -ok( $pid3 = open(FH3, "| $cmd3"), ' third' ); +{ + no warnings 'once'; + ok( $pid3 = open(FH3, "| $cmd3"), ' third' ); +} ok( $pid4 = open(FH4, "| $cmd4"), ' fourth' ); print "# pids were $pid1, $pid2, $pid3, $pid4\n"; diff --git a/t/io/pipe.t b/t/io/pipe.t index fd35512..d411719 100755 --- a/t/io/pipe.t +++ b/t/io/pipe.t @@ -167,6 +167,7 @@ SKIP: { # Test new semantics for missing command in piped open # 19990114 M-J. Dominus mjd@plover.com { local *P; + no warnings 'pipe'; ok( !open(P, "| "), 'missing command in piped open input' ); ok( !open(P, " |"), ' output'); } diff --git a/t/io/print.t b/t/io/print.t index 31d559a..2685b0a 100755 --- a/t/io/print.t +++ b/t/io/print.t @@ -48,6 +48,7 @@ if (!exists &Errno::EBADF) { print "ok 19 # skipped: no EBADF\n"; } else { $! = 0; + no warnings 'unopened'; print NONEXISTENT "foo"; print "not " if ($! != &Errno::EBADF); print "ok 19\n"; diff --git a/t/io/read.t b/t/io/read.t index 63ffee1..6d590ff 100755 --- a/t/io/read.t +++ b/t/io/read.t @@ -35,6 +35,7 @@ SKIP: { skip "no EBADF", 1 if (!exists &Errno::EBADF); $! = 0; + no warnings 'unopened'; read(B,$b,1); ok($! == &Errno::EBADF); } diff --git a/t/io/tell.t b/t/io/tell.t index dcb4ee9..9527876 100755 --- a/t/io/tell.t +++ b/t/io/tell.t @@ -9,7 +9,7 @@ BEGIN { print "1..28\n"; -$TST = 'tst'; +$TST = 'TST'; $Is_Dosish = ($^O eq 'MSWin32' or $^O eq 'NetWare' or $^O eq 'dos' or $^O eq 'os2' or $^O eq 'mint' or $^O eq 'cygwin' or @@ -17,13 +17,13 @@ $Is_Dosish = ($^O eq 'MSWin32' or $^O eq 'NetWare' or $^O eq 'dos' or open($TST, 'harness') || (die "Can't open harness"); binmode $TST if $Is_Dosish; -if (eof(tst)) { print "not ok 1\n"; } else { print "ok 1\n"; } +if (eof(TST)) { print "not ok 1\n"; } else { print "ok 1\n"; } $firstline = <$TST>; $secondpos = tell; $x = 0; -while () { +while () { if (eof) {$x++;} } if ($x == 1) { print "ok 2\n"; } else { print "not ok 2\n"; } @@ -36,17 +36,17 @@ if (seek($TST,0,0)) { print "ok 4\n"; } else { print "not ok 4\n"; } if (eof) { print "not ok 5\n"; } else { print "ok 5\n"; } -if ($firstline eq ) { print "ok 6\n"; } else { print "not ok 6\n"; } +if ($firstline eq ) { print "ok 6\n"; } else { print "not ok 6\n"; } if ($secondpos == tell) { print "ok 7\n"; } else { print "not ok 7\n"; } -if (seek(tst,0,1)) { print "ok 8\n"; } else { print "not ok 8\n"; } +if (seek(TST,0,1)) { print "ok 8\n"; } else { print "not ok 8\n"; } if (eof($TST)) { print "not ok 9\n"; } else { print "ok 9\n"; } if ($secondpos == tell) { print "ok 10\n"; } else { print "not ok 10\n"; } -if (seek(tst,0,2)) { print "ok 11\n"; } else { print "not ok 11\n"; } +if (seek(TST,0,2)) { print "ok 11\n"; } else { print "not ok 11\n"; } if ($lastpos == tell) { print "ok 12\n"; } else { print "not ok 12\n"; } @@ -55,19 +55,19 @@ unless (eof) { print "not ok 13\n"; } else { print "ok 13\n"; } if ($. == 0) { print "not ok 14\n"; } else { print "ok 14\n"; } $curline = $.; -open(other, 'harness') || (die "Can't open harness: $!"); -binmode other if (($^O eq 'MSWin32') || ($^O eq 'NetWare')); +open(OTHER, 'harness') || (die "Can't open harness: $!"); +binmode OTHER if (($^O eq 'MSWin32') || ($^O eq 'NetWare')); { local($.); if ($. == 0) { print "not ok 15\n"; } else { print "ok 15\n"; } - tell other; + tell OTHER; if ($. == 0) { print "ok 16\n"; } else { print "not ok 16\n"; } $. = 5; - scalar ; + scalar ; if ($. == 6) { print "ok 17\n"; } else { print "not ok 17\n"; } } @@ -76,7 +76,7 @@ if ($. == $curline) { print "ok 18\n"; } else { print "not ok 18\n"; } { local($.); - scalar ; + scalar ; if ($. == 7) { print "ok 19\n"; } else { print "not ok 19\n"; } } @@ -85,14 +85,19 @@ if ($. == $curline) { print "ok 20\n"; } else { print "not ok 20\n"; } { local($.); - tell other; + tell OTHER; if ($. == 7) { print "ok 21\n"; } else { print "not ok 21\n"; } } -close(other); -if (tell(other) == -1) { print "ok 22\n"; } else { print "not ok 22\n"; } - -if (tell(ether) == -1) { print "ok 23\n"; } else { print "not ok 23\n"; } +close(OTHER); +{ + no warnings 'closed'; + if (tell(OTHER) == -1) { print "ok 22\n"; } else { print "not ok 22\n"; } +} +{ + no warnings 'unopened'; + if (tell(ETHER) == -1) { print "ok 23\n"; } else { print "not ok 23\n"; } +} # ftell(STDIN) (or any std streams) is undefined, it can return -1 or # something else. ftell() on pipes, fifos, and sockets is defined to @@ -102,7 +107,7 @@ my $written = "tell_write.txt"; END { 1 while unlink($written) } -close($tst); +close($TST); open($tst,">$written") || die "Cannot open $written:$!"; binmode $tst if $Is_Dosish; -- 1.8.3.1