]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
We also need to look for templates that are INCLUDEd in other templates.
authorjake%acutex.net <>
Sun, 7 Oct 2001 04:37:20 +0000 (04:37 +0000)
committerjake%acutex.net <>
Sun, 7 Oct 2001 04:37:20 +0000 (04:37 +0000)
No review needed for tests at this time. NOT PART OF BUILD

t/004template.t
t/Support/Templates.pm

index 7077a6f173c02d9b6f97a01590f76d54444cb904..ce36683fcf0257cf0f34b7146055839b005998b2 100644 (file)
@@ -32,13 +32,14 @@ BEGIN { use Test::More tests => $tests; }
 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");
@@ -47,7 +48,7 @@ foreach my $file(@testitems) {
 
 # Processes all the templates to make sure they have good syntax
 my $template = Template->new ({
-                 INCLUDE_PATH => $path,
+                 INCLUDE_PATH => $include_path,
                  RELATIVE => 1
                  });
 
@@ -55,7 +56,7 @@ open SAVEOUT, ">&STDOUT";     # stash the original output stream
 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");
     }
index 360fdc4ccc62307cbaefe7bc02f5382a3671d592..8ae3926816d87332d7fde4ac5d08deff2a2cd962 100644 (file)
@@ -22,6 +22,8 @@
 
 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.
 
@@ -41,4 +43,19 @@ foreach my $file (@files) {
     }
 }
 
+# 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;