Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

harness

git-svn-id: https://pause.perl.org:5460/svn/pause/branches/unit_tests@982 a0804923-bdb8-0310-8f3c-e6a281b66435
  • Loading branch information...
commit 7490b912ad40e592f7770173abbba22b0c32100b 1 parent 5660088
authored March 29, 2008

Showing 1 changed file with 55 additions and 0 deletions. Show diff stats Hide diff stats

  1. 55  t/lib/PAUSE/Tester.pm
55  t/lib/PAUSE/Tester.pm
... ...
@@ -0,0 +1,55 @@
  1
+use strict;
  2
+use warnings;
  3
+
  4
+package PAUSE::Tester;
  5
+
  6
+use Test::FITesque;
  7
+use YAML::Syck;
  8
+use File::Basename;
  9
+
  10
+sub import {
  11
+  my $self = shift;
  12
+  return unless @_;
  13
+  die "invalid arguments: @_" unless $_[0] eq '-run';
  14
+  shift;
  15
+  $self->run(@_);
  16
+}
  17
+
  18
+sub run {
  19
+  my $self = shift;
  20
+  my $run_class = shift;
  21
+  unless ($run_class) {
  22
+    ($run_class = basename((caller)[1], '.t')) =~ s/-/::/g;
  23
+    $run_class = "PAUSE::Test::$run_class";
  24
+  }
  25
+
  26
+  my $data_dir = 't/data/' . ($run_class =~ /::([^:]+)$/)[0];
  27
+
  28
+  #warn "run_class[$run_class] data_dir[$data_dir]\n";
  29
+
  30
+  run_tests {
  31
+    suite {
  32
+      map {
  33
+        my ($method, $data) = @$_;
  34
+        if (ref $data eq 'ARRAY') {
  35
+          my $tests = $data;
  36
+          $data = {
  37
+            tests => $tests,
  38
+          }
  39
+        }
  40
+        test {
  41
+          [ $run_class, $data->{args} || {} ],
  42
+          map { [ $method, @$_ ] } @{$data->{tests}}
  43
+        }
  44
+      } 
  45
+      map {
  46
+        my $method = basename($_, '.yaml');
  47
+        map {
  48
+          [ $method, $_ ]
  49
+        } grep { defined } YAML::Syck::LoadFile($_);
  50
+      } <$data_dir/*.yaml>
  51
+    }
  52
+  };
  53
+}
  54
+
  55
+1;

0 notes on commit 7490b91

Please sign in to comment.
Something went wrong with that request. Please try again.