push @last, <pod/*.t>;
push @last, <x2p/*.t>;
+ 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 };
}