Skip to content

Commit

Permalink
If previous test run times are provided, use them to order tests
Browse files Browse the repository at this point in the history
Parallel tests should optimally be run from longest to shortest, to
minimize leftover time at the tail end of the testsuite.  If
previous-test-timing information is passed, use it to order tests:
  * Unknown tests go first, as they may be long
  * Otherwise, order by test length, longest to shortest
  * Finally, fall back to asciibetical
  • Loading branch information
alexmv committed May 4, 2014
1 parent 43df96b commit e53b299
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/Smokingit/Worker.pm
Expand Up @@ -99,6 +99,7 @@ sub run_tests {
my $env = $request->{env} || '';
my $jobs = $request->{parallel} ? $self->max_jobs : 1;
my $tests = $request->{test_glob} || 't/*.t';
my $prev = $request->{previous};

my $result = { smoke_id => $request->{smoke_id} };

Expand Down Expand Up @@ -182,10 +183,19 @@ sub run_tests {
if $ret;
}

# Figure out test order
my @tests = glob($tests);
if ($prev) {
# Put unknown tests first (alphabetically), followed by the
# rest, slowest to fastest.
@tests = sort { (defined($prev->{$a}) <=> defined($prev->{$b}))
or ( ($prev->{$b}||0) <=> ($prev->{$a}||0) )
or ( $a cmp $b )
} @tests;
}

# Progress indicator via Gearman
my $done = 0;
my @tests = glob($tests);
my $harness = TAP::Harness::AnyEvent->new( {
jobs => $jobs,
lib => [".", "lib"],
Expand Down

0 comments on commit e53b299

Please sign in to comment.