diff options
author | jake%acutex.net <> | 2001-10-28 00:27:31 +0200 |
---|---|---|
committer | jake%acutex.net <> | 2001-10-28 00:27:31 +0200 |
commit | d672813699ae015a80f79dcb7df5da65c1914c0a (patch) | |
tree | 0e2ed328875febe9bea336175498987a9151f6d7 /t | |
parent | a350cba23db498f94ecdbcfd0e5d7518aef00430 (diff) | |
download | bugzilla-d672813699ae015a80f79dcb7df5da65c1914c0a.tar.gz bugzilla-d672813699ae015a80f79dcb7df5da65c1914c0a.tar.xz |
A few enhancements to the template test:
* If there's a compilation error, report what it is
* Don't try to compile a template if it doesn't exist
- We already tested for that and issued an ERROR
* Define the 'url' FILTER
Diffstat (limited to 't')
-rw-r--r-- | t/004template.t | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/t/004template.t b/t/004template.t index 92d9c511c..2b1cfe0df 100644 --- a/t/004template.t +++ b/t/004template.t @@ -34,32 +34,56 @@ use Template; my @testitems = @Support::Templates::testitems; 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. +my %exists; foreach my $file(@testitems) { if (-e $include_path . "/" . $file) { ok(1, "$file exists"); + $exists{$file} = 1; } else { ok(0, "$file does not exist --ERROR"); } } # Processes all the templates to make sure they have good syntax -my $template = Template->new ({ - INCLUDE_PATH => $include_path, - RELATIVE => 1 - }); +my $template = Template->new( +{ + INCLUDE_PATH => $include_path , + RELATIVE => 1, + # Need to define filters used in the codebase, they don't + # actually have to function in this test, just be defined. + FILTERS => + { + url => sub { return $_ } , + } +} +); 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 ($template->process($file)) { - ok(1, "$file syntax ok"); - } else { - ok(0, "$file has bad syntax --ERROR"); + if ($exists{$file}) { + if ($template->process($file)) { + ok(1, "$file syntax ok"); + } + else { + print TESTOUT $template->error() . "\n"; + ok(0, "$file has bad syntax --ERROR"); + } + } + else { + ok(1, "$file doesn't exists, skipping test"); } } open STDOUT, ">&SAVEOUT"; # redirect back to original stream +open STDERR, ">&SAVEERR"; close SAVEOUT; +close SAVEERR; |