From: Robert Buels Date: Thu, 9 Jul 2009 22:33:23 +0000 (-0700) Subject: added little test_answers.pl script to run the exercise tests on the answers in a... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9b9f6a8b9ec7d696890176b7034b4f784f790c80;p=gitmo%2Fmoose-presentations.git added little test_answers.pl script to run the exercise tests on the answers in a TAP::Harness. cannot use prove here because you have to use a different lib dir for each test file that you run --- diff --git a/moose-class/exercises/answers/test_answers.pl b/moose-class/exercises/answers/test_answers.pl new file mode 100755 index 0000000..893202e --- /dev/null +++ b/moose-class/exercises/answers/test_answers.pl @@ -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 );