]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 680729 - Testing suite (runtests.pl) incorrectly plans to do its existence check...
authorMarc Schumann <wurblzap@gmail.com>
Wed, 31 Aug 2011 13:30:51 +0000 (15:30 +0200)
committerMarc Schumann <wurblzap@gmail.com>
Wed, 31 Aug 2011 13:30:51 +0000 (15:30 +0200)
r=dkl; a=mkanat

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

index d38ae37e260e09173a443d83394864007326cb9a..3b858c0b37c1b35fd5b4c4e8209bf1e377d32929 100644 (file)
@@ -38,8 +38,7 @@ use CGI qw(-no_debug);
 
 use File::Spec;
 use Template;
-use Test::More tests => ( scalar(@referenced_files) * scalar(@languages)
-                        + $num_actual_files );
+use Test::More tests => ( scalar(@referenced_files) + $num_actual_files );
 
 # Capture the TESTOUT from Test::More or Test::Builder for printing errors.
 # This will handle verbosity for us automatically.
@@ -55,24 +54,17 @@ my $fh;
     }
 }
 
-# Checks whether one of the passed files exists
-sub existOnce {
-  foreach my $file (@_) {
-    return $file  if -e $file;
-  }
-  return 0;
-}
-
-# Check to make sure all templates that are referenced in
-# Bugzilla exist in the proper place.
+# Check to make sure all templates that are referenced in Bugzilla
+# exist in the proper place in the English template directory.
+# All other languages may or may not include any template as Bugzilla will
+# fall back to English if necessary.
 
 foreach my $file (@referenced_files) {
-    my @path = map(File::Spec->catfile($_, $file), @include_paths);
-    if (my $path = existOnce(@path)) {
+    my $path = File::Spec->catfile($english_default_include_path, $file);
+    if (-e $path) {
         ok(1, "$path exists");
     } else {
-        ok(0, "$file cannot be located --ERROR");
-        print $fh "Looked in:\n  " . join("\n  ", @path) . "\n";
+        ok(0, "$path cannot be located --ERROR");
     }
 }
 
@@ -114,19 +106,17 @@ foreach my $include_path (@include_paths) {
 
     foreach my $file (@{$actual_files{$include_path}}) {
         my $path = File::Spec->catfile($include_path, $file);
-        if (-e $path) {
-            my ($data, $err) = $provider->fetch($file);
-
-            if (!$err) {
-                ok(1, "$file syntax ok");
-            }
-            else {
-                ok(0, "$file has bad syntax --ERROR");
-                print $fh $data . "\n";
-            }
+
+        # These are actual files, so there's no need to check for existence.
+
+        my ($data, $err) = $provider->fetch($file);
+
+        if (!$err) {
+            ok(1, "$path syntax ok");
         }
         else {
-            ok(1, "$path doesn't exist, skipping test");
+            ok(0, "$path has bad syntax --ERROR");
+            print $fh $data . "\n";
         }
     }
 }
index 90b63a72694ac117d42d926982effd3835ed6438..81dc8cc3f2c51997c2ea2b6028a40faca9571426 100644 (file)
@@ -29,12 +29,13 @@ use strict;
 use lib 't';
 use base qw(Exporter);
 @Support::Templates::EXPORT = 
-         qw(@languages @include_paths %include_path @referenced_files 
-            %actual_files $num_actual_files);
-use vars qw(@languages @include_paths %include_path @referenced_files 
-            %actual_files $num_actual_files);
+         qw(@languages @include_paths $english_default_include_path
+         %include_path @referenced_files %actual_files $num_actual_files);
+use vars qw(@languages @include_paths $english_default_include_path
+            %include_path @referenced_files %actual_files $num_actual_files);
 
 use Bugzilla;
+use Bugzilla::Constants;
 use Bugzilla::Install::Util qw(template_include_path);
 use Support::Files;
 
@@ -50,6 +51,10 @@ use File::Spec;
 # All include paths
 @include_paths = ();
 
+# English default include path
+$english_default_include_path =
+    File::Spec->catdir(bz_locations()->{'templatedir'}, 'en', 'default');
+
 # Files which are referenced in the cgi files
 @referenced_files = ();