X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fharness;h=e6e8d9e8f18c7522a221795cc70eb6b17890a50f;hb=28b1daef84496f2ebce3fad4ac7861dd4dd92f38;hp=bcf680901979c8c0cd4787613bb61a803954e924;hpb=e6867818d3d9ce24342ef3f6ceff06868f5e8457;p=p5sagit%2Fp5-mst-13.2.git
diff --git a/t/harness b/t/harness
index bcf6809..e6e8d9e 100644
--- a/t/harness
+++ b/t/harness
@@ -46,7 +46,7 @@ foreach (keys %datahandle) {
unlink "$_.t";
}
-my (@tests, $rules, $re);
+my (@tests, $re);
# [.VMS]TEST.COM calls harness with empty arguments, so clean-up @ARGV
@ARGV = grep $_ && length( $_ ) => @ARGV;
@@ -55,16 +55,6 @@ sub _populate_hash {
return map {$_, 1} split /\s+/, $_[0];
}
-sub _glob_and_parallelise {
- my @dirs;
- # Run the tests in each of these directories in sequence, but the
- # directories themselves can be parallelised.
- foreach (@_) {
- push @dirs, { seq => [ glob "$_/*.t" ] };
- }
- { par => \@dirs };
-}
-
# Generate T::H schedule rules that run the contents of each directory
# sequentially.
sub _seq_dir_rules {
@@ -94,7 +84,7 @@ sub _extract_tests {
die "Unknown reference type $ref";
}
} else {
- push @results, $_;
+ push @results, glob $_;
}
}
@results;
@@ -110,7 +100,27 @@ if ($ARGV[0] && $ARGV[0]=~/^-re/) {
}
}
+my $jobs = $ENV{TEST_JOBS};
+my ($fork, $rules, $state);
+if ($ENV{HARNESS_OPTIONS}) {
+ for my $opt ( split /:/, $ENV{HARNESS_OPTIONS} ) {
+ if ( $opt =~ /^j(\d*)$/ ) {
+ $jobs ||= $1 || 9;
+ }
+ elsif ( $opt eq 'f' ) {
+ $fork = 1;
+ }
+ elsif ( $opt eq 'c' ) {
+# $args->{color} = 1;
+ }
+ else {
+ die "Unknown HARNESS_OPTIONS item: $opt\n";
+ }
+ }
+}
+
if (@ARGV) {
+ # If you want these run in speed order, just use prove
if ($^O eq 'MSWin32') {
@tests = map(glob($_),@ARGV);
}
@@ -133,17 +143,35 @@ if (@ARGV) {
# nice to get the tests in t/op/*.t able to run in parallel.
unless (@tests) {
- my @seq;
- push @seq, ;
+ my @seq = ;
- push @seq, _glob_and_parallelise qw(comp cmd run io);
- my @next = qw(uni mro lib);
+ my @next = qw(comp cmd run io op uni mro lib);
push @next, 'japh' if $torture;
push @next, 'win32' if $^O eq 'MSWin32';
- push @seq, { par => [
- {seq => [ glob "op/*.t" ]},
- map { glob "$_/*.t" } @next
+ # Hopefully TAP::Parser::Scheduler will support this syntax soon.
+ # my $next = { par => '{' . join (',', @next) . '}/*.t' };
+ my $next = { par => [
+ map { "$_/*.t" } @next
] };
+ @tests = _extract_tests ($next);
+
+ # This is a bit of a game, because we only want to sort these tests in
+ # speed order. base/*.t wants to run first, and ext,lib etc last and in
+ # MANIFEST order
+ if ($jobs) {
+ require App::Prove::State;
+ $state = App::Prove::State->new({ store => 'test_state' });
+ $state->apply_switch('slow', 'save');
+ # For some reason get_tests returns *all* the tests previously run,
+ # (in the right order), not simply the selection in @tests
+ # (in the right order). Not sure if this is a bug or a feature.
+ # Whatever, *we* are only interested in the ones that are in @tests
+ my %seen;
+ @seen{@tests} = ();
+ @tests = grep {exists $seen{$_} } $state->get_tests(0, @tests);
+ }
+ @tests = (@seq, @tests);
+ push @seq, $next;
my @last;
use Config;
@@ -183,12 +211,11 @@ if (@ARGV) {
push @last, ;
push @last, ;
- @tests = (_extract_tests (@seq), @last);
+ push @tests, @last;
push @seq, _seq_dir_rules @last;
$rules = { seq => \@seq };
-
}
}
if ($^O eq 'MSWin32') {
@@ -197,10 +224,19 @@ if ($^O eq 'MSWin32') {
@tests=grep /$re/, @tests
if $re;
-my $jobs = $ENV{TEST_JOBS};
if ($jobs) {
eval 'use TAP::Harness 3.13; 1' or die $@;
- my $h = TAP::Harness->new({ jobs => $jobs, rules => $rules});
+
+ # Test::Harness parses $ENV{HARNESS_OPTIONS}, TAP::Harness does not
+ local $ENV{HARNESS_OPTIONS};
+ my $h = TAP::Harness->new({ jobs => $jobs, rules => $rules, ($fork ? (fork => $fork) : ())});
+ if ($state) {
+ $h->callback(
+ after_test => sub {
+ $state->observe_test(@_);
+ }
+ );
+ }
$h->runtests(@tests);
} else {
Test::Harness::runtests @tests;