Commit 205a682a authored by Marc Schumann's avatar Marc Schumann

Bug 680729 - Testing suite (runtests.pl) incorrectly plans to do its existence…

Bug 680729 - Testing suite (runtests.pl) incorrectly plans to do its existence check on referenced templates more than once. r=dkl; a=mkanat
parent bc484d1a
...@@ -38,8 +38,7 @@ use CGI qw(-no_debug); ...@@ -38,8 +38,7 @@ use CGI qw(-no_debug);
use File::Spec; use File::Spec;
use Template; use Template;
use Test::More tests => ( scalar(@referenced_files) * scalar(@languages) use Test::More tests => ( scalar(@referenced_files) + $num_actual_files );
+ $num_actual_files );
# Capture the TESTOUT from Test::More or Test::Builder for printing errors. # Capture the TESTOUT from Test::More or Test::Builder for printing errors.
# This will handle verbosity for us automatically. # This will handle verbosity for us automatically.
...@@ -55,24 +54,17 @@ my $fh; ...@@ -55,24 +54,17 @@ my $fh;
} }
} }
# Checks whether one of the passed files exists # Check to make sure all templates that are referenced in Bugzilla
sub existOnce { # exist in the proper place in the English template directory.
foreach my $file (@_) { # All other languages may or may not include any template as Bugzilla will
return $file if -e $file; # fall back to English if necessary.
}
return 0;
}
# Check to make sure all templates that are referenced in
# Bugzilla exist in the proper place.
foreach my $file (@referenced_files) { foreach my $file (@referenced_files) {
my @path = map(File::Spec->catfile($_, $file), @include_paths); my $path = File::Spec->catfile($english_default_include_path, $file);
if (my $path = existOnce(@path)) { if (-e $path) {
ok(1, "$path exists"); ok(1, "$path exists");
} else { } else {
ok(0, "$file cannot be located --ERROR"); ok(0, "$path cannot be located --ERROR");
print $fh "Looked in:\n " . join("\n ", @path) . "\n";
} }
} }
...@@ -114,19 +106,17 @@ foreach my $include_path (@include_paths) { ...@@ -114,19 +106,17 @@ foreach my $include_path (@include_paths) {
foreach my $file (@{$actual_files{$include_path}}) { foreach my $file (@{$actual_files{$include_path}}) {
my $path = File::Spec->catfile($include_path, $file); my $path = File::Spec->catfile($include_path, $file);
if (-e $path) {
my ($data, $err) = $provider->fetch($file); # These are actual files, so there's no need to check for existence.
if (!$err) { my ($data, $err) = $provider->fetch($file);
ok(1, "$file syntax ok");
} if (!$err) {
else { ok(1, "$path syntax ok");
ok(0, "$file has bad syntax --ERROR");
print $fh $data . "\n";
}
} }
else { else {
ok(1, "$path doesn't exist, skipping test"); ok(0, "$path has bad syntax --ERROR");
print $fh $data . "\n";
} }
} }
} }
......
...@@ -29,12 +29,13 @@ use strict; ...@@ -29,12 +29,13 @@ use strict;
use lib 't'; use lib 't';
use base qw(Exporter); use base qw(Exporter);
@Support::Templates::EXPORT = @Support::Templates::EXPORT =
qw(@languages @include_paths %include_path @referenced_files qw(@languages @include_paths $english_default_include_path
%actual_files $num_actual_files); %include_path @referenced_files %actual_files $num_actual_files);
use vars qw(@languages @include_paths %include_path @referenced_files use vars qw(@languages @include_paths $english_default_include_path
%actual_files $num_actual_files); %include_path @referenced_files %actual_files $num_actual_files);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Install::Util qw(template_include_path); use Bugzilla::Install::Util qw(template_include_path);
use Support::Files; use Support::Files;
...@@ -50,6 +51,10 @@ use File::Spec; ...@@ -50,6 +51,10 @@ use File::Spec;
# All include paths # All include paths
@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 # Files which are referenced in the cgi files
@referenced_files = (); @referenced_files = ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment