2001-10-06 22:59:36 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Mozilla Public
|
|
|
|
# License Version 1.1 (the "License"); you may not use this file
|
|
|
|
# except in compliance with the License. You may obtain a copy of
|
|
|
|
# the License at http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
# implied. See the License for the specific language governing
|
|
|
|
# rights and limitations under the License.
|
|
|
|
#
|
|
|
|
# The Original Code are the Bugzilla tests.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Jacob Steenhagen.
|
|
|
|
# Portions created by Jacob Steenhagen are
|
|
|
|
# Copyright (C) 2001 Jacob Steenhagen. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s): Jacob Steenhagen <jake@acutex.net>
|
|
|
|
#
|
|
|
|
|
|
|
|
#################
|
|
|
|
#Bugzilla Test 4#
|
|
|
|
##Templates######
|
|
|
|
|
|
|
|
BEGIN { use lib "t/"; }
|
|
|
|
BEGIN { use Support::Templates; }
|
|
|
|
BEGIN { $tests = @Support::Templates::testitems * 2; }
|
|
|
|
BEGIN { use Test::More tests => $tests; }
|
|
|
|
|
2001-10-20 02:39:51 +04:00
|
|
|
use strict;
|
2001-10-06 22:59:36 +04:00
|
|
|
use Template;
|
|
|
|
|
|
|
|
my @testitems = @Support::Templates::testitems;
|
2001-10-07 01:37:22 +04:00
|
|
|
my $include_path = $Support::Templates::include_path;
|
2001-10-27 19:27:31 +04:00
|
|
|
# Capture the TESTERR from Test::More for printing errors.
|
|
|
|
# This will handle verbosity for us automatically
|
|
|
|
*TESTOUT = \*Test::More::TESTOUT;
|
2001-10-06 22:59:36 +04:00
|
|
|
|
|
|
|
# Check to make sure all templates that are referenced in
|
|
|
|
# Bugzilla exist in the proper place.
|
2001-10-07 01:37:22 +04:00
|
|
|
|
2001-10-27 19:27:31 +04:00
|
|
|
my %exists;
|
2001-10-06 22:59:36 +04:00
|
|
|
foreach my $file(@testitems) {
|
2001-10-07 01:37:22 +04:00
|
|
|
if (-e $include_path . "/" . $file) {
|
2001-10-06 22:59:36 +04:00
|
|
|
ok(1, "$file exists");
|
2001-10-27 19:27:31 +04:00
|
|
|
$exists{$file} = 1;
|
2001-10-06 22:59:36 +04:00
|
|
|
} else {
|
2001-10-13 00:35:37 +04:00
|
|
|
ok(0, "$file does not exist --ERROR");
|
2001-10-06 22:59:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Processes all the templates to make sure they have good syntax
|
2001-10-27 19:27:31 +04:00
|
|
|
my $template = Template->new(
|
|
|
|
{
|
|
|
|
INCLUDE_PATH => $include_path ,
|
|
|
|
RELATIVE => 1,
|
|
|
|
# Need to define filters used in the codebase, they don't
|
|
|
|
# actually have to function in this test, just be defined.
|
|
|
|
FILTERS =>
|
|
|
|
{
|
|
|
|
url => sub { return $_ } ,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2001-10-06 22:59:36 +04:00
|
|
|
|
|
|
|
open SAVEOUT, ">&STDOUT"; # stash the original output stream
|
2001-10-27 19:27:31 +04:00
|
|
|
open SAVEERR, ">&STDERR";
|
2001-10-06 22:59:36 +04:00
|
|
|
open STDOUT, "> /dev/null"; # discard all output
|
2001-10-27 19:27:31 +04:00
|
|
|
open STDERR, "> /dev/null";
|
2001-10-06 22:59:36 +04:00
|
|
|
foreach my $file(@testitems) {
|
2001-10-27 19:27:31 +04:00
|
|
|
if ($exists{$file}) {
|
|
|
|
if ($template->process($file)) {
|
|
|
|
ok(1, "$file syntax ok");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print TESTOUT $template->error() . "\n";
|
|
|
|
ok(0, "$file has bad syntax --ERROR");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ok(1, "$file doesn't exists, skipping test");
|
2001-10-06 22:59:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
open STDOUT, ">&SAVEOUT"; # redirect back to original stream
|
2001-10-27 19:27:31 +04:00
|
|
|
open STDERR, ">&SAVEERR";
|
2001-10-06 22:59:36 +04:00
|
|
|
close SAVEOUT;
|
2001-10-27 19:27:31 +04:00
|
|
|
close SAVEERR;
|