use Template;
my @testitems = @Support::Templates::testitems;
+my $include_path = $Support::Templates::include_path;
my $verbose = $::ENV{VERBOSE};
# Check to make sure all templates that are referenced in
# Bugzilla exist in the proper place.
-my $path = "template/default";
+
foreach my $file(@testitems) {
- if (-e $path . "/" . $file) {
+ if (-e $include_path . "/" . $file) {
ok(1, "$file exists");
} else {
ok(0, "$file does not exist");
# Processes all the templates to make sure they have good syntax
my $template = Template->new ({
- INCLUDE_PATH => $path,
+ INCLUDE_PATH => $include_path,
RELATIVE => 1
});
open STDOUT, "> /dev/null"; # discard all output
foreach my $file(@testitems) {
if ($template->process($file)) {
- ok(1, "$file");
+ ok(1, "$file syntax ok");
} else {
ok(0, "$file has bad syntax");
}
package Support::Templates;
+$include_path = "template/default";
+
# Scan Bugzilla's code looking for templates used and put them
# in the @testitems array to be used by the template.t test.
}
}
+# Now let's look at the templates and find any other templates
+# that are INCLUDEd.
+foreach my $file(@testitems) {
+ open (FILE, $include_path . "/" . $file) || next;
+ my @lines = <FILE>;
+ close (FILE);
+ foreach my $line (@lines) {
+ if ($line =~ m/\[% INCLUDE (.+?) /) {
+ my $template = $1;
+ push (@testitems, $template) unless $t{$template};
+ $t{$template} = 1;
+ }
+ }
+}
+
1;