Test zur Prüfung der Syntax aller Template::Toolkit-Templates
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 3 Nov 2015 14:25:36 +0000 (15:25 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 3 Nov 2015 14:25:36 +0000 (15:25 +0100)
t/template_syntax.t [new file with mode: 0644]

diff --git a/t/template_syntax.t b/t/template_syntax.t
new file mode 100644 (file)
index 0000000..b1b4224
--- /dev/null
@@ -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;