summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-08-09 20:11:55 +0000
committerNicholas Clark <nick@ccl4.org>2008-08-09 20:11:55 +0000
commit0279961e65f24cb3d5407ae9771030dcc5eb6882 (patch)
tree8628b9b768ac38dfcd2a78c4bf150901246807ab /t
parent2f4cffa7723545b6812f9ecf0e78635684033dad (diff)
downloadperl-0279961e65f24cb3d5407ae9771030dcc5eb6882.tar.gz
Use App::Prove::State to store the timings for the tests, and if
timings are available, reorder the parallelisable tests to run the slowest first. Timings for a second run are 18 seconds less for me: Files=1553, Tests=209393, 459 wallclock secs (94.89 usr 13.16 sys + 638.19 cusr 58.59 csys = 804.83 CPU) Files=1553, Tests=209393, 441 wallclock secs (82.83 usr 13.90 sys + 622.13 cusr 59.20 csys = 778.06 CPU) p4raw-id: //depot/perl@34192
Diffstat (limited to 't')
-rw-r--r--t/harness43
1 files changed, 36 insertions, 7 deletions
diff --git a/t/harness b/t/harness
index a701fc765a..8a4e9b4c3a 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;
@@ -100,7 +100,11 @@ if ($ARGV[0] && $ARGV[0]=~/^-re/) {
}
}
+my $jobs = $ENV{TEST_JOBS};
+my ($rules, $state);
+
if (@ARGV) {
+ # If you want these run in speed order, just use prove
if ($^O eq 'MSWin32') {
@tests = map(glob($_),@ARGV);
}
@@ -123,15 +127,35 @@ if (@ARGV) {
# nice to get the tests in t/op/*.t able to run in parallel.
unless (@tests) {
- my @seq;
- push @seq, <base/*.t>;
+ my @seq = <base/*.t>;
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 => [
+ # 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;
@@ -171,12 +195,11 @@ if (@ARGV) {
push @last, <pod/*.t>;
push @last, <x2p/*.t>;
- @tests = (_extract_tests (@seq), @last);
+ push @tests, @last;
push @seq, _seq_dir_rules @last;
$rules = { seq => \@seq };
-
}
}
if ($^O eq 'MSWin32') {
@@ -185,10 +208,16 @@ 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});
+ if ($state) {
+ $h->callback(
+ after_test => sub {
+ $state->observe_test(@_);
+ }
+ );
+ }
$h->runtests(@tests);
} else {
Test::Harness::runtests @tests;