summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2010-01-23 21:23:01 +0100
committerJean Delvare <jdelvare@suse.de>2010-01-23 21:23:01 +0100
commitaec8cb5d622a24c1d3ce7a06cfc50e037fb676e7 (patch)
tree3d1beff315e4d7669fb6fdaba85c9980ab843309 /test
parentf1458bf10fe56cb4f95f446bf35bcd09a55f6ecd (diff)
downloadquilt-aec8cb5d622a24c1d3ce7a06cfc50e037fb676e7.tar.gz
Let the test suite be run in parallel
Add an option to the test case runner script to generate an output suitable for parallel runs: * Print the full output at the end of the test case, all at once. * Only output the detailed commands on failed test cases. This makes it possible and convenient to run the test suite in parallel on SMP systems.
Diffstat (limited to 'test')
-rwxr-xr-xtest/run58
1 files changed, 50 insertions, 8 deletions
diff --git a/test/run b/test/run
index 49d1c2d..0ed950e 100755
--- a/test/run
+++ b/test/run
@@ -40,12 +40,12 @@ use strict;
use FileHandle;
use Getopt::Std;
use POSIX qw(isatty setuid getcwd);
-use vars qw($opt_l $opt_v);
+use vars qw($opt_l $opt_q $opt_v %output);
no warnings qw(taint);
$opt_l = ~0; # a really huge number
-getopts('l:v');
+getopts('l:qv');
my ($OK, $FAILED) = ("ok", "failed");
if (isatty(fileno(STDOUT))) {
@@ -55,6 +55,10 @@ if (isatty(fileno(STDOUT))) {
sub exec_test($$);
sub process_test($$$$);
+sub print_header($);
+sub print_body($);
+sub print_footer($);
+sub flush_output($);
my ($prog, $in, $out) = ([], [], []);
my $prog_line = 0;
@@ -71,6 +75,7 @@ $ENV{PWD} = getcwd;
if (defined $ARGV[0]) {
open(SOURCE, "$origdir/$ARGV[0]");
+ print_header "[$ARGV[0]]\n";
} else {
*SOURCE = *STDIN;
}
@@ -121,7 +126,8 @@ if (isatty(fileno(STDOUT))) {
$status = "\033[32m" . $status . "\033[m";
}
}
-print $status, "\n";
+print_footer "$status\n";
+flush_output $failed;
exit $failed ? 1 : 0;
@@ -131,8 +137,8 @@ sub process_test($$$$) {
return unless @$prog;
my $p = [ @$prog ];
- print "[$prog_line] \$ ", join(' ',
- map { s/\s/\\$&/g; $_ } @$p), " -- ";
+ print_body "[$prog_line] \$ ".join(' ',
+ map { s/\s/\\$&/g; $_ } @$p)." -- ";
my $result = exec_test($prog, $in);
my @good = ();
my $nmax = (@$out > @$result) ? @$out : @$result;
@@ -155,15 +161,15 @@ sub process_test($$$$) {
my $good = !(grep /!/, @good);
$tests++;
$failed++ unless $good;
- print $good ? $OK : $FAILED, "\n";
+ print_body(($good ? $OK : $FAILED)."\n");
if (!$good || $opt_v) {
for (my $n=0; $n < $nmax; $n++) {
my $l = defined($out->[$n]) ? $out->[$n] : "~";
chomp $l;
my $r = defined($result->[$n]) ? $result->[$n] : "~";
chomp $r;
- print sprintf("%-" . ($width-3) . "s %s %s\n",
- $r, $good[$n], $l);
+ print_body sprintf("%-" . ($width-3) . "s %s %s\n",
+ $r, $good[$n], $l);
}
}
}
@@ -341,3 +347,39 @@ sub exec_test($$) {
}
}
+sub print_header($)
+{
+ if ($opt_q) {
+ $output{header} = $_[0];
+ } else {
+ print $_[0];
+ }
+}
+
+sub print_body($)
+{
+ if ($opt_q) {
+ $output{body} .= $_[0];
+ } else {
+ print $_[0];
+ }
+}
+
+sub print_footer($)
+{
+ if ($opt_q) {
+ $output{footer} .= $_[0];
+ } else {
+ print $_[0];
+ }
+}
+
+sub flush_output($)
+{
+ my $failed = shift;
+ return unless $opt_q;
+
+ print $output{header} || "",
+ $failed ? $output{body} : "",
+ $output{footer} || "";
+}