X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=blobdiff_plain;f=wvtest;h=7d494f348185713ea0c44d80d9959ea74448f936;hp=7541ebd63b951f30e047336a60d5db7161785e1a;hb=00fb1f1b2a53935ca7d5ce95ea4cf56b7f9bcc3d;hpb=13612bf383392a9f8430717ced1bb2a26622c7b4 diff --git a/wvtest b/wvtest index 7541ebd..7d494f3 100755 --- a/wvtest +++ b/wvtest @@ -12,6 +12,11 @@ use Getopt::Long qw(GetOptionsFromArray :config no_ignore_case bundling); use Pod::Usage; use Time::HiRes qw(time); +my $per_test_warn_time = 100000; # upstream was 500 +my $per_test_bad_time = 100000; # upstream was 1000 +my $overall_test_warn_time = 100000; # upstream was 2000 +my $overall_test_bad_time = 100000; # upstream was 5000 + my $pid; my $istty = -t STDOUT; my @log = (); @@ -80,12 +85,18 @@ sub endsect() { $stop = time(); if ($start) { - printf " %s %s\n", mstime($stop - $start, 500, 1000), colourize("ok"); + printf " %s %s\n", + mstime($stop - $start, $per_test_warn_time, $per_test_bad_time), + colourize("ok"); } } -sub run() +sub run { + # dup_msgs should be true when "watching". In that case all top + # level wvtest protocol messages should be duplicated to stderr so + # that they can be safely captured for report to process later. + my ($dup_msgs) = @_; my $show_counts = 1; GetOptionsFromArray(\@ARGV, 'counts!', \$show_counts) or pod2usage(); @@ -94,7 +105,11 @@ sub run() # always flush $| = 1; - print STDERR "Testing \"all\" in @ARGV:\n"; + { + my $msg = "Testing \"all\" in @ARGV:\n"; + print $msg; + print STDERR $msg if $dup_msgs; + } $pid = open(my $fh, "-|"); if (!$pid) { @@ -110,7 +125,8 @@ sub run() local $SIG{INT} = sub { bigkill($pid); }; local $SIG{TERM} = sub { bigkill($pid); }; local $SIG{ALRM} = sub { - print STDERR "Alarm timed out! No test results for too long.\n"; + print STDERR resultline('Alarm timed out! No test results for too long.\n', + 'FAILED'); bigkill($pid); }; @@ -122,7 +138,7 @@ sub run() if (/^\s*Testing "(.*)" in (.*):\s*$/) { - alarm(120); + alarm(300); my ($sect, $file) = ($1, $2); endsect(); @@ -133,7 +149,7 @@ sub run() } elsif (/^!\s*(.*?)\s+(\S+)\s*$/) { - alarm(120); + alarm(300); my ($name, $result) = ($1, $2); my $pass = ($result eq "ok"); @@ -181,18 +197,29 @@ sub run() } if ($code != 0) { - print resultline("Program returned non-zero exit code ($ret)", "FAILED"); + my $msg = resultline("Program returned non-zero exit code ($ret)", + 'FAILED'); + print $msg; + print STDERR "$msg\n" if $dup_msgs; } print "\n"; if ($show_counts) { my $gtotal = $gpasses + $gfails; - printf("WvTest: %d test%s, %d failure%s\n", - $gtotal, $gtotal==1 ? "" : "s", - $gfails, $gfails==1 ? "" : "s"); + my $msg = sprintf("WvTest: %d test%s, %d failure%s\n", + $gtotal, $gtotal == 1 ? "" : "s", $gfails, + $gfails == 1 ? "" : "s"); + print $msg; + print STDERR $msg if $dup_msgs; + } + { + my $msg = sprintf("WvTest: result code $ret, total time %s\n", + mstime(time() - $allstart, + $overall_test_warn_time, + $overall_test_bad_time)); + print $msg; + print STDERR $msg if $dup_msgs; } - printf("WvTest: result code $ret, total time %s\n", - mstime(time() - $allstart, 2000, 5000)); return ($ret ? $ret : ($gfails ? 125 : 0)); } @@ -250,8 +277,8 @@ pod2usage(-msg => "$0: no action specified", -verbose => 1) if (@ARGV < 1); my $action = $ARGV[0]; shift @ARGV; -if ($action eq 'run') { exit run(); } -elsif ($action eq 'watch') { run(); } +if ($action eq 'run') { exit run(0); } +elsif ($action eq 'watch') { run(1); } elsif ($action eq 'report') { exit report(); } else { pod2usage(-msg => "$0: invalid action $action", -verbose => 1); } @@ -287,9 +314,12 @@ B as described in the EXAMPLES below. # Fine if ./tests doesn't produce any output in parallel. wvtest run ./tests - # Use watch and report for parallel tests. + # Use watch and report for parallel tests. Note that watch's stderr will + # include copies of any top level messages - reporting non-zero + # test command exits, etc., and so must be included in the report arguments. wvtest watch --no-counts \ - sh -c '(test-1 2>&1 | tee test-1.log)& (test-2 2>&1 | tee test-2.log)&' - wvtest report test-1.log test-2.log + "sh -c '(test-1 2>&1 | tee test-1.log)& (test-2 2>&1 | tee test-2.log)&'" \ + 2>test-3.log \ + wvtest report test-1.log test-2.log test-3.log =cut