diff options
author | zach%zachlipton.com <> | 2002-05-09 08:49:31 +0200 |
---|---|---|
committer | zach%zachlipton.com <> | 2002-05-09 08:49:31 +0200 |
commit | ccf9d404cfe99346af2f08dbbda44a3a53912b90 (patch) | |
tree | e8d3de7e241b998d8dc5498852873938632316b9 /t/001compile.t | |
parent | 1d10fae35ea91b2e038cc8d3942a1860415e5dde (diff) | |
download | bugzilla-ccf9d404cfe99346af2f08dbbda44a3a53912b90.tar.gz bugzilla-ccf9d404cfe99346af2f08dbbda44a3a53912b90.tar.xz |
Fix for bug 143124, Fix warning messages about *::TESTOUT and clean up
test code. Patch makes the tests much better now.
r=zach x2
Diffstat (limited to 't/001compile.t')
-rw-r--r-- | t/001compile.t | 86 |
1 files changed, 45 insertions, 41 deletions
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 = <FILE>; - 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 = <FILE>; + 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; |