summaryrefslogtreecommitdiffstats
path: root/t/004template.t
diff options
context:
space:
mode:
authorbbaetz%student.usyd.edu.au <>2002-05-07 18:45:28 +0200
committerbbaetz%student.usyd.edu.au <>2002-05-07 18:45:28 +0200
commit4afae456014ff01ee01e11279fc5a9b5f4f7b5bf (patch)
treeeb8b4a2372819cf21850d8369263726791425cfa /t/004template.t
parentb8465474ad9cc187ba020b16609ff6a1933d4e17 (diff)
downloadbugzilla-4afae456014ff01ee01e11279fc5a9b5f4f7b5bf.tar.gz
bugzilla-4afae456014ff01ee01e11279fc5a9b5f4f7b5bf.tar.xz
Bug 135543 - @Support::Templates::testitems does not list all templates
Patch by ddkilzer@theracingworld.com (David D. Kilzer), r=gerv, justdave
Diffstat (limited to 't/004template.t')
-rw-r--r--t/004template.t44
1 files changed, 25 insertions, 19 deletions
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 <jake@acutex.net>
-# Zach Lipton <zach@zachlipton.com>
+# Zach Lipton <zach@zachlipton.com>
+# David D. Kilzer <ddkilzer@kilzer.net>
#
#################
#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 = <TMPL>;
if ($firstline =~ /\d+\.\d+\@[\w\.-]+/) {
ok(1,"$file has a version string");