Revision 5dba1d4a
Von Moritz Bunkus vor etwa 9 Jahren hinzugefügt
t/template_syntax.t | ||
---|---|---|
1 |
use strict; |
|
2 |
|
|
3 |
use lib 't'; |
|
4 |
|
|
5 |
use Support::Templates; |
|
6 |
|
|
7 |
use File::Spec; |
|
8 |
use File::Slurp; |
|
9 |
use Template; |
|
10 |
use Template::Provider; |
|
11 |
use Test::More tests => ( scalar(@referenced_files)); |
|
12 |
|
|
13 |
my $template_path = 'templates/webpages/'; |
|
14 |
|
|
15 |
my $provider = Template::Provider->new({ |
|
16 |
INTERPOLATE => 0, |
|
17 |
EVAL_PERL => 0, |
|
18 |
ABSOLUTE => 1, |
|
19 |
CACHE_SIZE => 0, |
|
20 |
PLUGIN_BASE => 'SL::Template::Plugin', |
|
21 |
INCLUDE_PATH => '.:' . $template_path, |
|
22 |
}); |
|
23 |
|
|
24 |
foreach my $ref (@Support::Templates::referenced_files) { |
|
25 |
my $file = "${template_path}${ref}.html"; |
|
26 |
my ($result, $not_ok) = $provider->fetch($file); |
|
27 |
|
|
28 |
if (!$not_ok) { |
|
29 |
ok(1, "${file} does not contain errors"); |
|
30 |
|
|
31 |
} elsif (ref($result) eq 'Template::Exception') { |
|
32 |
print STDERR $result->as_string; |
|
33 |
ok(0, "${file} contains syntax errors"); |
|
34 |
|
|
35 |
} else { |
|
36 |
die "Unknown result type: " . ref($result); |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
40 |
exit 0; |
Auch abrufbar als: Unified diff
Test zur Prüfung der Syntax aller Template::Toolkit-Templates