From: Andreas König Date: Thu, 27 Dec 2001 09:47:30 +0000 (+0100) Subject: [PATCH] check return of close X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f126f811c9f2a4fefd11f07d5e3babaa75ee3158;p=p5sagit%2Fp5-mst-13.2.git [PATCH] check return of close Date: 27 Dec 2001 09:47:30 +0100 Message-ID: Subject: [PATCH] improve error reporting From: andreas.koenig@anima.de (Andreas J. Koenig) Date: 27 Dec 2001 09:54:55 +0100 Message-ID: Subject: [PATCH] check return value of close From: andreas.koenig@anima.de (Andreas J. Koenig) Date: 27 Dec 2001 10:03:55 +0100 Message-ID: Subject: [PATCH] return of close From: andreas.koenig@anima.de (Andreas J. Koenig) Date: 27 Dec 2001 10:22:15 +0100 Message-ID: p4raw-id: //depot/perl@13904 --- diff --git a/ext/IO/lib/IO/t/io_dir.t b/ext/IO/lib/IO/t/io_dir.t index a6f03d0..75979a3 100755 --- a/ext/IO/lib/IO/t/io_dir.t +++ b/ext/IO/lib/IO/t/io_dir.t @@ -41,7 +41,7 @@ print defined($dot->read) ? "not ok" : "ok", " 5\n"; open(FH,'>X') || die "Can't create x"; print FH "X"; -close(FH); +close(FH) or die "Can't close: $!"; tie %dir, IO::Dir, $DIR; my @files = keys %dir; diff --git a/lib/warnings.t b/lib/warnings.t index b6daebc..c88a4d9 100644 --- a/lib/warnings.t +++ b/lib/warnings.t @@ -1,4 +1,4 @@ -#!./perl +#!./perl BEGIN { chdir 't' if -d 't'; @@ -33,13 +33,13 @@ foreach my $file (@w_files) { open F, "<$file" or die "Cannot open $file: $!\n" ; my $line = 0; while () { - $line++; + $line++; last if /^__END__/ ; } { local $/ = undef; - $files++; + $files++; @prgs = (@prgs, $file, split "\n########\n", ) ; } close F ; @@ -48,13 +48,13 @@ foreach my $file (@w_files) { undef $/; print "1..", scalar(@prgs)-$files, "\n"; - - + + for (@prgs){ unless (/\n/) { - print "# From $_\n"; - next; + print "# From $_\n"; + next; } my $switch = ""; my @temps = () ; @@ -66,7 +66,7 @@ for (@prgs){ if ( $prog =~ /--FILE--/) { my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ; shift @files ; - die "Internal error test $i didn't split into pairs, got " . + die "Internal error test $i didn't split into pairs, got " . scalar(@files) . "[" . join("%%%%", @files) ."]\n" if @files % 2 ; while (@files > 2) { @@ -75,21 +75,21 @@ for (@prgs){ push @temps, $filename ; open F, ">$filename" or die "Cannot open $filename: $!\n" ; print F $code ; - close F ; + close F or die "Cannot close $filename: $!\n"; } shift @files ; $prog = shift @files ; } - open TEST, ">$tmpfile"; + open TEST, ">$tmpfile" or die "Cannot open >$tmpfile: $!"; print TEST q{ - BEGIN { - open(STDERR, ">&STDOUT") + BEGIN { + open(STDERR, ">&STDOUT") or die "Can't dup STDOUT->STDERR: $!;"; } }; print TEST "\n#line 1\n"; # So the line numbers don't get messed up. print TEST $prog,"\n"; - close TEST; + close TEST or die "Cannot close $tmpfile: $!"; my $results = $Is_VMS ? `./perl "-I../lib" $switch $tmpfile` : $Is_MSWin32 ? @@ -141,6 +141,6 @@ for (@prgs){ print "not "; } print "ok ", ++$i, "\n"; - foreach (@temps) - { unlink $_ if $_ } + foreach (@temps) + { unlink $_ if $_ } } diff --git a/t/cmd/subval.t b/t/cmd/subval.t index 3c60690..67a4ebf 100755 --- a/t/cmd/subval.t +++ b/t/cmd/subval.t @@ -114,14 +114,14 @@ package main; $i = 28; open(FOO,">Cmd_subval.tmp"); print FOO "blah blah\n"; -close FOO; +close FOO or die "Can't close Cmd_subval.tmp: $!"; &file_main(*F); -close F; +close F or die "Can't close: $!"; &info_main; &file_package(*F); -close F; +close F or die "Can't close: $!"; &info_package; unlink 'Cmd_subval.tmp'; @@ -129,7 +129,7 @@ unlink 'Cmd_subval.tmp'; sub file_main { local(*F) = @_; - open(F, 'Cmd_subval.tmp') || die "can't open\n"; + open(F, 'Cmd_subval.tmp') || die "can't open: $!\n"; $i++; eof F ? print "not ok $i\n" : print "ok $i\n"; } @@ -137,11 +137,11 @@ sub file_main { sub info_main { local(*F); - open(F, 'Cmd_subval.tmp') || die "test: can't open\n"; + open(F, 'Cmd_subval.tmp') || die "test: can't open: $!\n"; $i++; eof F ? print "not ok $i\n" : print "ok $i\n"; &iseof(*F); - close F; + close F or die "Can't close: $!"; } sub iseof { @@ -156,7 +156,7 @@ sub iseof { sub main'file_package { local(*F) = @_; - open(F, 'Cmd_subval.tmp') || die "can't open\n"; + open(F, 'Cmd_subval.tmp') || die "can't open: $!\n"; $main'i++; eof F ? print "not ok $main'i\n" : print "ok $main'i\n"; } @@ -164,7 +164,7 @@ sub iseof { sub main'info_package { local(*F); - open(F, 'Cmd_subval.tmp') || die "can't open\n"; + open(F, 'Cmd_subval.tmp') || die "can't open: $!\n"; $main'i++; eof F ? print "not ok $main'i\n" : print "ok $main'i\n"; &iseof(*F); diff --git a/t/io/fflush.t b/t/io/fflush.t index 6c22fa6..fbf6b47 100644 --- a/t/io/fflush.t +++ b/t/io/fflush.t @@ -66,7 +66,7 @@ print OUT $str; close OUT; EOF ; -close PROG; +close PROG or die "close ff-prog: $!";; push @delete, "ff-prog"; $| = 0; # we want buffered output @@ -122,7 +122,7 @@ for (qw(system qx popen)) { my $command = qq{$runperl "ff-prog" "$f" "rl"}; open OUT, "> $f" or die "open $f: $!"; print OUT "Pe"; - close OUT; + close OUT or die "close $f: $!";; print "# $command\n"; $code->($command); print file_eq($f, "Perl") ? "ok $t\n" : "not ok $t\n";