Permalink
Browse files

harness

git-svn-id: https://pause.perl.org:5460/svn/pause/branches/unit_tests@982 a0804923-bdb8-0310-8f3c-e6a281b66435
  • Loading branch information...
1 parent 5660088 commit 7490b912ad40e592f7770173abbba22b0c32100b hdp committed Mar 29, 2008
Showing with 55 additions and 0 deletions.
  1. +55 −0 t/lib/PAUSE/Tester.pm
View
@@ -0,0 +1,55 @@
+use strict;
+use warnings;
+
+package PAUSE::Tester;
+
+use Test::FITesque;
+use YAML::Syck;
+use File::Basename;
+
+sub import {
+ my $self = shift;
+ return unless @_;
+ die "invalid arguments: @_" unless $_[0] eq '-run';
+ shift;
+ $self->run(@_);
+}
+
+sub run {
+ my $self = shift;
+ my $run_class = shift;
+ unless ($run_class) {
+ ($run_class = basename((caller)[1], '.t')) =~ s/-/::/g;
+ $run_class = "PAUSE::Test::$run_class";
+ }
+
+ my $data_dir = 't/data/' . ($run_class =~ /::([^:]+)$/)[0];
+
+ #warn "run_class[$run_class] data_dir[$data_dir]\n";
+
+ run_tests {
+ suite {
+ map {
+ my ($method, $data) = @$_;
+ if (ref $data eq 'ARRAY') {
+ my $tests = $data;
+ $data = {
+ tests => $tests,
+ }
+ }
+ test {
+ [ $run_class, $data->{args} || {} ],
+ map { [ $method, @$_ ] } @{$data->{tests}}
+ }
+ }
+ map {
+ my $method = basename($_, '.yaml');
+ map {
+ [ $method, $_ ]
+ } grep { defined } YAML::Syck::LoadFile($_);
+ } <$data_dir/*.yaml>
+ }
+ };
+}
+
+1;

0 comments on commit 7490b91

Please sign in to comment.