From ccf9d404cfe99346af2f08dbbda44a3a53912b90 Mon Sep 17 00:00:00 2001 From: "zach%zachlipton.com" <> Date: Thu, 9 May 2002 06:49:31 +0000 Subject: Fix for bug 143124, Fix warning messages about *::TESTOUT and clean up test code. Patch makes the tests much better now. r=zach x2 --- t/001compile.t | 86 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 41 deletions(-) (limited to 't/001compile.t') diff --git a/t/001compile.t b/t/001compile.t index 561aacf45..f662f0751 100644 --- a/t/001compile.t +++ b/t/001compile.t @@ -32,57 +32,61 @@ # GPL. # - ################# #Bugzilla Test 1# ###Compilation### -BEGIN { use lib 't/'; } -BEGIN { use Support::Files; } -BEGIN { $tests = @Support::Files::testitems; } -BEGIN { use Test::More tests => $tests; } use strict; -# First now we test the scripts -my @testitems = @Support::Files::testitems; -# Capture the TESTERR from Test::More for printing errors. -# This will handle verbosity for us automatically -*TESTOUT = \*Test::More::TESTOUT; -my $perlapp = $^X; - -foreach my $file (@testitems) { - $file =~ s/\s.*$//; # nuke everything after the first space (#comment) - next if (!$file); # skip null entries - open (FILE,$file); - my $bang = ; - close (FILE); - my $T = ""; - if ($bang =~ m/#!\S*perl\s+-.*T/) { - $T = "T"; - } - my $command = "$perlapp"." -c$T $file 2>&1"; - my $loginfo=`$command`; - #print '@@'.$loginfo.'##'; - if ($loginfo =~ /syntax ok$/im) { - if ($loginfo ne "$file syntax OK\n") { - print TESTOUT $loginfo; - ok(0,$file."--WARNING"); - } else { - ok(1,$file); - } - } else { - print TESTOUT $loginfo; - ok(0,$file."--ERROR"); - } -} - -# Remove the lib testing from here since it is now done -# in Files.pm - +use lib 't'; +use Support::Files; +use Test::More tests => scalar(@Support::Files::testitems); +# Capture the TESTOUT from Test::More or Test::Builder for printing errors. +# This will handle verbosity for us automatically. +my $fh; +{ + local $^W = 0; # Don't complain about non-existent filehandles + if (-e \*Test::More::TESTOUT) { + $fh = \*Test::More::TESTOUT; + } elsif (-e \*Test::Builder::TESTOUT) { + $fh = \*Test::Builder::TESTOUT; + } else { + $fh = \*STDOUT; + } +} +my @testitems = @Support::Files::testitems; +my $perlapp = $^X; +# Test the scripts by compiling them +foreach my $file (@testitems) { + $file =~ s/\s.*$//; # nuke everything after the first space (#comment) + next if (!$file); # skip null entries + open (FILE,$file); + my $bang = ; + close (FILE); + my $T = ""; + if ($bang =~ m/#!\S*perl\s+-.*T/) { + $T = "T"; + } + my $command = "$perlapp -c$T $file 2>&1"; + my $loginfo=`$command`; + #print '@@'.$loginfo.'##'; + if ($loginfo =~ /syntax ok$/im) { + if ($loginfo ne "$file syntax OK\n") { + ok(0,$file." --WARNING"); + print $fh $loginfo; + } else { + ok(1,$file); + } + } else { + ok(0,$file." --ERROR"); + print $fh $loginfo; + } +} +exit 0; -- cgit v1.2.3-24-g4f1b