Tests: Ensure TT2 templates parse cleanly
authorDan Scott <dscott@laurentian.ca>
Sat, 13 Oct 2012 05:23:35 +0000 (01:23 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 9 Jan 2014 14:45:08 +0000 (09:45 -0500)
File::Find and Test::Output make it easy to check for any stderr
returned from the TT2 extractor.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/t/22-template-toolkit-parse.t [new file with mode: 0644]

diff --git a/Open-ILS/src/perlmods/t/22-template-toolkit-parse.t b/Open-ILS/src/perlmods/t/22-template-toolkit-parse.t
new file mode 100644 (file)
index 0000000..08304f6
--- /dev/null
@@ -0,0 +1,28 @@
+use strict;
+use warnings;
+use File::Find;
+use File::Spec;
+use Locale::Maketext::Extract;
+use Test::More;
+use Test::Output;
+
+my $num_tests = 0;
+
+my $ext = Locale::Maketext::Extract->new(
+    plugins => { tt2  => ['tt2'] },
+    warnings => 1,
+    verbose => 0
+);
+
+sub template_checker {
+    return unless /.tt2$/;
+    my $tt2 = $_;
+    $num_tests++;
+    stderr_is {$ext->extract_file($tt2)} '', "Parse TT2 - $File::Find::name";
+}
+
+my ($vol, $dir, $file) = File::Spec->splitpath(__FILE__);
+chdir("$dir/../..");
+find(\&template_checker, ('templates'));
+
+done_testing($num_tests);