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/004template.t | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 't/004template.t') diff --git a/t/004template.t b/t/004template.t index f9cd0fad9..f56a30140 100644 --- a/t/004template.t +++ b/t/004template.t @@ -26,7 +26,6 @@ #Bugzilla Test 4# ####Templates#### -use diagnostics; use strict; use lib 't'; @@ -41,10 +40,21 @@ use Template; use Test::More tests => ( scalar(@Support::Templates::referenced_files) + scalar(@Support::Templates::actual_files) * 2); +# 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 $include_path = $Support::Templates::include_path; -# Capture the TESTERR from Test::More for printing errors. -# This will handle verbosity for us automatically -*TESTOUT = \*Test::More::TESTOUT; # Check to make sure all templates that are referenced in # Bugzilla exist in the proper place. @@ -86,8 +96,8 @@ foreach my $file(@Support::Templates::actual_files) { ok(1, "$file syntax ok"); } else { - print TESTOUT $template->error() . "\n"; ok(0, "$file has bad syntax --ERROR"); + print $fh $template->error() . "\n"; } } else { @@ -112,3 +122,5 @@ foreach my $file(@Support::Templates::actual_files) { } close(TMPL); } + +exit 0; -- cgit v1.2.3-24-g4f1b