unlink "$_.t";
}
-my (@tests, $re);
+my (@tests, $rules, $re);
# [.VMS]TEST.COM calls harness with empty arguments, so clean-up @ARGV
@ARGV = grep $_ && length( $_ ) => @ARGV;
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 {
+ my @tests = @_;
+ my %dir;
+ for (@tests) {
+ s{[^/]+$}{\*};
+ $dir{$_}++;
+ }
+
+ return { par => [ map { { seq => $_ } } sort keys %dir ] };
+}
+
+sub _extract_tests;
+sub _extract_tests {
+ # This can probably be done more tersely with a map, but I doubt that it
+ # would be as clear
+ my @results;
+ foreach (@_) {
+ my $ref = ref $_;
+ if ($ref) {
+ if ($ref eq 'ARRAY') {
+ push @results, _extract_tests @$_;
+ } elsif ($ref eq 'HASH') {
+ push @results, _extract_tests values %$_;
+ } else {
+ die "Unknown reference type $ref";
+ }
+ } else {
+ push @results, $_;
+ }
+ }
+ @results;
+}
+
if ($ARGV[0] && $ARGV[0]=~/^-re/) {
if ($ARGV[0]!~/=/) {
shift;
@tests = @ARGV;
}
} else {
+ # Ideally we'd get somewhere close to Tux's Oslo rules
+ # my $rules = {
+ # par => [
+ # { seq => '../ext/DB_File/t/*' },
+ # { seq => '../ext/IO_Compress_Zlib/t/*' },
+ # { seq => '../lib/CPANPLUS/*' },
+ # { seq => '../lib/ExtUtils/t/*' },
+ # '*'
+ # ]
+ # };
+
+ # but for now, run all directories in sequence. In particular, it would be
+ # nice to get the tests in t/op/*.t able to run in parallel.
+
unless (@tests) {
- push @tests, <base/*.t>;
- push @tests, <comp/*.t>;
- push @tests, <cmd/*.t>;
- push @tests, <run/*.t>;
- push @tests, <io/*.t>;
- push @tests, <op/*.t>;
- push @tests, <uni/*.t>;
- push @tests, <mro/*.t>;
- push @tests, <lib/*.t>;
- push @tests, <japh/*.t> if $torture;
- push @tests, <win32/*.t> if $^O eq 'MSWin32';
+ my @seq;
+ push @seq, <base/*.t>;
+
+ push @seq, _glob_and_parallelise qw(comp cmd run io);
+ my @next = qw(op uni mro lib);
+ push @next, 'japh' if $torture;
+ push @next, 'win32' if $^O eq 'MSWin32';
+ push @seq, _glob_and_parallelise @next;
+
+ my @last;
use Config;
my %skip;
{
close MANI;
# Sort the list of test files read from MANIFEST into a sensible
# order instead of using the order in which they are listed there
- push @tests, sort { lc $a cmp lc $b } @manitests;
+ push @last, sort { lc $a cmp lc $b } @manitests;
} else {
warn "$0: cannot open $mani: $!\n";
}
- push @tests, <Module_Pluggable/*.t>;
- push @tests, <pod/*.t>;
- push @tests, <x2p/*.t>;
+ push @last, <Module_Pluggable/*.t>;
+ push @last, <pod/*.t>;
+ push @last, <x2p/*.t>;
+
+ @tests = (_extract_tests (@seq), @last);
+
+ push @seq, _seq_dir_rules @last;
+
+ $rules = { seq => \@seq };
+
}
}
if ($^O eq 'MSWin32') {
}
@tests=grep /$re/, @tests
if $re;
-Test::Harness::runtests @tests;
+
+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});
+ $h->runtests(@tests);
+} else {
+ Test::Harness::runtests @tests;
+}
exit(0);