From 5dba1d4a26ad134882a22e47e4f3c632a73d4b7a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 3 Nov 2015 15:25:36 +0100 Subject: [PATCH] =?utf8?q?Test=20zur=20Pr=C3=BCfung=20der=20Syntax=20aller?= =?utf8?q?=20Template::Toolkit-Templates?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- t/template_syntax.t | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 t/template_syntax.t diff --git a/t/template_syntax.t b/t/template_syntax.t new file mode 100644 index 000000000..b1b4224bf --- /dev/null +++ b/t/template_syntax.t @@ -0,0 +1,40 @@ +use strict; + +use lib 't'; + +use Support::Templates; + +use File::Spec; +use File::Slurp; +use Template; +use Template::Provider; +use Test::More tests => ( scalar(@referenced_files)); + +my $template_path = 'templates/webpages/'; + +my $provider = Template::Provider->new({ + INTERPOLATE => 0, + EVAL_PERL => 0, + ABSOLUTE => 1, + CACHE_SIZE => 0, + PLUGIN_BASE => 'SL::Template::Plugin', + INCLUDE_PATH => '.:' . $template_path, +}); + +foreach my $ref (@Support::Templates::referenced_files) { + my $file = "${template_path}${ref}.html"; + my ($result, $not_ok) = $provider->fetch($file); + + if (!$not_ok) { + ok(1, "${file} does not contain errors"); + + } elsif (ref($result) eq 'Template::Exception') { + print STDERR $result->as_string; + ok(0, "${file} contains syntax errors"); + + } else { + die "Unknown result type: " . ref($result); + } +} + +exit 0; -- 2.20.1