added little test_answers.pl script to run the exercise tests on the answers in a...
Robert Buels [Thu, 9 Jul 2009 22:33:23 +0000 (15:33 -0700)]
moose-class/exercises/answers/test_answers.pl [new file with mode: 0755]

diff --git a/moose-class/exercises/answers/test_answers.pl b/moose-class/exercises/answers/test_answers.pl
new file mode 100755 (executable)
index 0000000..893202e
--- /dev/null
@@ -0,0 +1,35 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use FindBin;
+use TAP::Harness;
+
+
+### construct a hash of test_filename => answer_libdir
+my %test2anslib =
+    map {
+        my $answer_libdir = $_;
+        my ($exercise_num) = $answer_libdir =~ m!/(\d+)-!
+            or die "can't parse dir name '$answer_libdir'";
+
+        map {$_ => $answer_libdir}
+        glob "$FindBin::RealBin/../t/$exercise_num-*.t";
+    }
+    # filter to find just answer libdirs
+    grep m!/\d+-[\w-]+/$!,
+    # list all dirs below this t/ dir
+    glob "$FindBin::RealBin/*/"; 
+
+
+
+my $harness = TAP::Harness->new({
+    failures => 1,
+    exec => sub {
+        my ($h,$testfile) = @_;
+        my $ans_libdir = $test2anslib{$testfile} or die "test file $testfile not found??";
+        [$^X, "-I$ans_libdir", $testfile ]
+    },
+});
+
+chdir "$FindBin::RealBin/../";
+$harness->runtests( sort keys %test2anslib );