Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Notice when test processes get terminated by SIGINT: stop processing …
…tests and just show summary
  • Loading branch information
Geoffrey Broadwell committed May 26, 2012
1 parent 71c3c79 commit ede2944
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
1 change: 0 additions & 1 deletion TODO
@@ -1,5 +1,4 @@
* Features
+ Notice when child processes have been killed by signal and DWIM better
+ Add Pugs to known compilers
+ Document data expected from each test, and analysis of results
+ Output to multiple formats: ANSI text, plain text, JSON, HTML
Expand Down
32 changes: 17 additions & 15 deletions bench
Expand Up @@ -187,34 +187,33 @@ MAIN();
sub MAIN {
my @results;

for my $test_type (sort keys %TESTS) {
my $results = run_tests($test_type, $TESTS{$test_type});
push @results, @$results;
}
eval {
for my $test_type (sort keys %TESTS) {
run_tests($test_type, $TESTS{$test_type}, \@results);
}
};
warn "\n$@\n" if $@;

summarize_results(\@results);
}

sub run_tests {
my ($test_type, $tests) = @_;
my @times;
my ($test_type, $tests, $results) = @_;

for my $test (@$tests) {
my $name = $test->{name};
say "Testing $name ...";
my $raw_times = time_all_compilers($test_type => %$test);
my $best = best_times($raw_times);
my $compared = compare_times($best);
push @times, {
name => $name,
conf => $test,
raw => $raw_times,
best => $best,
compare => $compared,
};
push @$results, {
name => $name,
conf => $test,
raw => $raw_times,
best => $best,
compare => $compared,
};
}

return \@times;
}

sub time_all_compilers {
Expand Down Expand Up @@ -274,6 +273,7 @@ sub time_command {
my $start = time;
my ($out, $err) = capture { $status = system @$compile };
if ($status) {
die "Test's compile command terminated by SIGINT.\n" if ($status & 127) == 2;
warn "Failed to run compile command: @$compile\n"
. (length $err ? "Error:\n$err\n" : '');
return undef;
Expand All @@ -287,6 +287,7 @@ sub time_command {
$status = system @run;
push @times, time - $start;
if ($status) {
die "Test's run command terminated by SIGINT.\n" if ($status & 127) == 2;
warn "Failed to run command: @run\n";
return undef;
}
Expand All @@ -296,6 +297,7 @@ sub time_command {
$status = system @$run;
push @times, time - $start;
if ($status) {
die "Test terminated by SIGINT.\n" if ($status & 127) == 2;
warn "Failed to run command: @$run\n";
return undef;
}
Expand Down

0 comments on commit ede2944

Please sign in to comment.