From: Nicholas Clark Date: Sun, 9 Aug 2009 09:44:28 +0000 (+0100) Subject: Run the main tests "slowest first" by ordering the rules correctly. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=226de479579f4a84dd17654b44e5aef323b0a403;p=p5sagit%2Fp5-mst-13.2.git Run the main tests "slowest first" by ordering the rules correctly. (It seems that the current TAP::Harness implementation sequences based on the parallel/serial rules, not the order of the list of test names presented to it.) --- diff --git a/t/harness b/t/harness index c2fbbee..9e3af04 100644 --- a/t/harness +++ b/t/harness @@ -200,19 +200,31 @@ if (@ARGV) { push @last, ; push @last, ; + my %times; + if ($state) { + # Where known, collate the elapsed times by test name + foreach ($state->results->tests()) { + $times{$_->name} = $_->elapsed(); + } + } + + my %dir; + my %total_time; + + for (@last) { + m!(.*/)! or die "'$_'"; + push @{$dir{$1}}, $_; + $total_time{$1} += $times{$_} || 0; + } + push @tests, @last; # Generate T::H schedule rules that run the contents of each directory # sequentially. - { - my %dir; - for (@last) { - s{[^/]+$}{\*}; - $dir{$_}++; - } - - push @seq, { par => [ map { { seq => $_ } } sort keys %dir ] }; - } + push @seq, { par => [ map { { seq => "$_*" } } sort { + # Directories, ordered by total time descending then name ascending + $total_time{$b} <=> $total_time{$a} || $a cmp $b + } keys %dir ] }; $rules = { seq => \@seq }; }