mirror of
https://github.com/mirror/wget.git
synced 2025-03-03 14:20:34 +08:00
Add colors to test summary.
This commit is contained in:
parent
cf4c155c0c
commit
7fc9281833
@ -1,3 +1,9 @@
|
||||
2008-11-07 Steven Schubiger <stsc@members.fsf.org>
|
||||
|
||||
* run-px: Use some colors for the summary part of the test
|
||||
output to strengthen the distinction between a successful
|
||||
or failing run.
|
||||
|
||||
2008-11-06 Steven Schubiger <stsc@members.fsf.org>
|
||||
|
||||
* run-px: When executing test scripts, invoke them with the
|
||||
|
67
tests/run-px
67
tests/run-px
@ -1,7 +1,12 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use 5.006;
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use Term::ANSIColor ':constants';
|
||||
$Term::ANSIColor::AUTORESET = 1;
|
||||
|
||||
die "Please specify the top source directory.\n" if (!@ARGV);
|
||||
my $top_srcdir = shift @ARGV;
|
||||
|
||||
@ -48,26 +53,56 @@ my @tests = (
|
||||
'Test--spider-r.px',
|
||||
);
|
||||
|
||||
my @results;
|
||||
my @tested;
|
||||
|
||||
for my $test (@tests) {
|
||||
foreach my $test (@tests) {
|
||||
print "Running $test\n\n";
|
||||
system("$^X $top_srcdir/tests/$test");
|
||||
push @results, $?;
|
||||
}
|
||||
|
||||
for (my $i=0; $i != @tests; ++$i) {
|
||||
if ($results[$i] == 0) {
|
||||
print "pass: ";
|
||||
} else {
|
||||
print "FAIL: ";
|
||||
}
|
||||
print "$tests[$i]\n";
|
||||
push @tested, { name => $test, result => $? };
|
||||
}
|
||||
|
||||
print "\n";
|
||||
print scalar(@results) . " tests were run\n";
|
||||
print scalar(grep $_ == 0, @results) . " PASS\n";
|
||||
print scalar(grep $_ != 0, @results) . " FAIL\n";
|
||||
foreach my $test (@tested) {
|
||||
($test->{result} == 0)
|
||||
? print GREEN 'pass: '
|
||||
: print RED 'FAIL: ';
|
||||
print $test->{name}, "\n";
|
||||
}
|
||||
|
||||
exit scalar (grep $_ != 0, @results);
|
||||
my $count = sub
|
||||
{
|
||||
return {
|
||||
pass => sub { scalar grep $_->{result} == 0, @tested },
|
||||
fail => sub { scalar grep $_->{result} != 0, @tested },
|
||||
}->{$_[0]}->();
|
||||
};
|
||||
|
||||
my $summary = sub
|
||||
{
|
||||
my @lines = (
|
||||
"${\scalar @tested} tests were run",
|
||||
"${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
|
||||
);
|
||||
my $len_longest = sub
|
||||
{
|
||||
local $_ = 0;
|
||||
foreach my $line (@lines) {
|
||||
if (length $line > $_) {
|
||||
$_ = length $line;
|
||||
}
|
||||
}
|
||||
return $_;
|
||||
}->();
|
||||
return join "\n",
|
||||
'=' x $len_longest,
|
||||
@lines,
|
||||
'=' x $len_longest;
|
||||
}->();
|
||||
|
||||
print "\n";
|
||||
print $count->('fail')
|
||||
? RED $summary
|
||||
: GREEN $summary;
|
||||
print "\n";
|
||||
|
||||
exit $count->('fail');
|
||||
|
Loading…
Reference in New Issue
Block a user