diff options
author | Jean Delvare <jdelvare@suse.de> | 2010-01-23 21:23:01 +0100 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2010-01-23 21:23:01 +0100 |
commit | aec8cb5d622a24c1d3ce7a06cfc50e037fb676e7 (patch) | |
tree | 3d1beff315e4d7669fb6fdaba85c9980ab843309 | |
parent | f1458bf10fe56cb4f95f446bf35bcd09a55f6ecd (diff) | |
download | quilt-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.
-rw-r--r-- | Makefile.in | 3 | ||||
-rw-r--r-- | quilt.changes | 1 | ||||
-rwxr-xr-x | test/run | 58 |
3 files changed, 52 insertions, 10 deletions
diff --git a/Makefile.in b/Makefile.in index 95c896e..331035d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -407,12 +407,11 @@ test/.%.ok : test/%.test FORCE else test/.%.ok : test/%.test endif - @echo "[$(<F)]" @LANG=C; LC_ALL=C; \ export LANG LC_ALL; \ $(CHECK_ENV); \ cd $(@D); \ - ./run $(<F) + ./run -q $(<F) @touch $@ clean : diff --git a/quilt.changes b/quilt.changes index 594607d..933b08d 100644 --- a/quilt.changes +++ b/quilt.changes @@ -3,6 +3,7 @@ Sat Jan 23 21:11:12 CET 2010 - jdelvare@suse.de - test/run, test/*.test: Separate working directory for each test case. +- Makefile.in, test/run: Let the test suite be run in parallel. ------------------------------------------------------------------- Sat Jan 23 17:59:33 CET 2010 - hertzog@debian.org @@ -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} || ""; +} |