X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=wvtestrun;h=183e066fbf5ad3bc34c106880ae005601ae9e2c9;hb=refs%2Fheads%2Fcleanup-messages;hp=4be41e3ee19f51aa6e51fa15e42d9ee9927590a2;hpb=01d3e5009888f80d940c6b7f585e96e98ae48cfd;p=bup.git diff --git a/wvtestrun b/wvtestrun index 4be41e3..183e066 100755 --- a/wvtestrun +++ b/wvtestrun @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl # # WvTest: # Copyright (C)2007-2009 Versabanq Innovations Inc. and contributors. @@ -6,6 +6,7 @@ # See the included file named LICENSE for license information. # use strict; +use warnings; use Time::HiRes qw(time); # always flush @@ -34,11 +35,11 @@ my ($gpasses, $gfails) = (0,0); sub bigkill($) { my $pid = shift; - + if (@log) { print "\n" . join("\n", @log) . "\n"; } - + print STDERR "\n! Killed by signal FAILED\n"; ($pid > 0) || die("pid is '$pid'?!\n"); @@ -46,19 +47,19 @@ sub bigkill($) local $SIG{CHLD} = sub { }; # this will wake us from sleep() faster kill 15, $pid; sleep(2); - + if ($pid > 1) { kill 9, -$pid; } kill 9, $pid; - + exit(125); } # parent local $SIG{INT} = sub { bigkill($pid); }; local $SIG{TERM} = sub { bigkill($pid); }; -local $SIG{ALRM} = sub { +local $SIG{ALRM} = sub { print STDERR "Alarm timed out! No test results for too long.\n"; bigkill($pid); }; @@ -67,7 +68,7 @@ sub colourize($) { my $result = shift; my $pass = ($result eq "ok"); - + if ($istty) { my $colour = $pass ? "\e[32;1m" : "\e[31;1m"; return "$colour$result\e[0m"; @@ -81,7 +82,7 @@ sub mstime($$$) my ($floatsec, $warntime, $badtime) = @_; my $ms = int($floatsec * 1000); my $str = sprintf("%d.%03ds", $ms/1000, $ms % 1000); - + if ($istty && $ms > $badtime) { return "\e[31;1m$str\e[0m"; } elsif ($istty && $ms > $warntime) { @@ -112,14 +113,14 @@ while (<$fh>) { chomp; s/\r//g; - + if (/^\s*Testing "(.*)" in (.*):\s*$/) { alarm(120); my ($sect, $file) = ($1, $2); - + endsect(); - + printf("! %s %s: ", $file, $sect); @log = (); $start = $stop; @@ -127,17 +128,17 @@ while (<$fh>) elsif (/^!\s*(.*?)\s+(\S+)\s*$/) { alarm(120); - + my ($name, $result) = ($1, $2); my $pass = ($result eq "ok"); - + if (!$start) { printf("\n! Startup: "); $start = time(); } - + push @log, resultline($name, $result); - + if (!$pass) { $gfails++; if (@log) {