From 4afae456014ff01ee01e11279fc5a9b5f4f7b5bf Mon Sep 17 00:00:00 2001 From: "bbaetz%student.usyd.edu.au" <> Date: Tue, 7 May 2002 16:45:28 +0000 Subject: Bug 135543 - @Support::Templates::testitems does not list all templates Patch by ddkilzer@theracingworld.com (David D. Kilzer), r=gerv, justdave --- t/004template.t | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 't/004template.t') diff --git a/t/004template.t b/t/004template.t index a63dbd64f..4332e2e82 100644 --- a/t/004template.t +++ b/t/004template.t @@ -18,25 +18,29 @@ # Rights Reserved. # # Contributor(s): Jacob Steenhagen -# Zach Lipton +# Zach Lipton +# David D. Kilzer # ################# #Bugzilla Test 4# ####Templates#### -BEGIN { use lib "t/"; } -BEGIN { use Support::Templates; } -BEGIN { $tests = @Support::Templates::testitems * 3; } -BEGIN { use Test::More tests => $tests; } - +use diagnostics; use strict; -use Template; + +use lib 't'; + +use Support::Templates; # Bug 137589 - Disable command-line input of CGI.pm when testing use CGI qw(-no_debug); -my @testitems = @Support::Templates::testitems; +use File::Spec 0.82; +use Template; +use Test::More tests => ( scalar(@Support::Templates::referenced_files) + + scalar(@Support::Templates::actual_files) * 2); + my $include_path = $Support::Templates::include_path; # Capture the TESTERR from Test::More for printing errors. # This will handle verbosity for us automatically @@ -45,13 +49,12 @@ my $include_path = $Support::Templates::include_path; # Check to make sure all templates that are referenced in # Bugzilla exist in the proper place. -my %exists; -foreach my $file(@testitems) { - if (-e $include_path . "/" . $file) { - ok(1, "$file exists"); - $exists{$file} = 1; +foreach my $file(@Support::Templates::referenced_files) { + my $path = File::Spec->catfile($include_path, $file); + if (-e $path) { + ok(1, "$path exists"); } else { - ok(0, "$file does not exist --ERROR"); + ok(0, "$path does not exist --ERROR"); } } @@ -61,6 +64,7 @@ my $template = Template->new( INCLUDE_PATH => $include_path , # Need to define filters used in the codebase, they don't # actually have to function in this test, just be defined. + # See globals.pl for the actual codebase definitions. FILTERS => { js => sub { return $_ } , @@ -74,8 +78,9 @@ open SAVEOUT, ">&STDOUT"; # stash the original output stream open SAVEERR, ">&STDERR"; open STDOUT, "> /dev/null"; # discard all output open STDERR, "> /dev/null"; -foreach my $file(@testitems) { - if ($exists{$file}) { +foreach my $file(@Support::Templates::actual_files) { + my $path = File::Spec->catfile($include_path, $file); + if (-e $path) { if ($template->process($file)) { ok(1, "$file syntax ok"); } @@ -85,7 +90,7 @@ foreach my $file(@testitems) { } } else { - ok(1, "$file doesn't exist, skipping test"); + ok(1, "$path doesn't exist, skipping test"); } } open STDOUT, ">&SAVEOUT"; # redirect back to original stream @@ -95,8 +100,9 @@ close SAVEERR; # check to see that all templates have a version string: -foreach my $file(@testitems) { - open(TMPL,"$include_path/$file"); +foreach my $file(@Support::Templates::actual_files) { + my $path = File::Spec->catfile($include_path, $file); + open(TMPL, $path); my $firstline = ; if ($firstline =~ /\d+\.\d+\@[\w\.-]+/) { ok(1,"$file has a version string"); -- cgit v1.2.3-24-g4f1b