summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/004template.t44
-rw-r--r--t/Support/Templates.pm13
2 files changed, 26 insertions, 31 deletions
diff --git a/t/004template.t b/t/004template.t
index d38ae37e2..3b858c0b3 100644
--- a/t/004template.t
+++ b/t/004template.t
@@ -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";
}
}
}
diff --git a/t/Support/Templates.pm b/t/Support/Templates.pm
index 90b63a726..81dc8cc3f 100644
--- a/t/Support/Templates.pm
+++ b/t/Support/Templates.pm
@@ -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 = ();