quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH 2/2] Let the test suite be run in parallel


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 2/2] Let the test suite be run in parallel
Date: Sun, 13 Dec 2009 18:15:15 +0100
User-agent: KMail/1.9.1

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.

---
 Makefile.in |    3 +--
 test/run    |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 51 insertions(+), 10 deletions(-)

--- 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 :
--- 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} || "";
+}

-- 
Jean Delvare
Suse L3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]