X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=tests%2Frun-px;h=3ab1c444f9d438c3b9f37e72539fe270970b0f3e;hp=3852071406af3b0b020bc78ac8675e66349ac4f7;hb=289ff1c86acbd60e09cb15d22df62b8e19942c3e;hpb=523c3dfcbc3e6858ea94288554d67d3c1208a7c1 diff --git a/tests/run-px b/tests/run-px index 38520714..3ab1c444 100755 --- a/tests/run-px +++ b/tests/run-px @@ -1,11 +1,19 @@ #!/usr/bin/env perl + +use 5.006; +use strict; use warnings; +use Term::ANSIColor ':constants'; +$Term::ANSIColor::AUTORESET = 1; + die "Please specify the top source directory.\n" if (!@ARGV); my $top_srcdir = shift @ARGV; my @tests = ( 'Test-auth-basic.px', + 'Test-auth-no-challenge.px', + 'Test-auth-no-challenge-url.px', 'Test-proxy-auth-basic.px', 'Test-proxied-https-auth.px', 'Test-N-HTTP-Content-Disposition.px', @@ -57,26 +65,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("$top_srcdir/tests/$test"); - push @results, $?; + system("$^X $top_srcdir/tests/$test"); + push @tested, { name => $test, result => $? }; } -for (my $i=0; $i != @tests; ++$i) { - if ($results[$i] == 0) { - print "pass: "; - } else { - print "FAIL: "; - } - print "$tests[$i]\n"; +print "\n"; +foreach my $test (@tested) { + ($test->{result} == 0) + ? print GREEN 'pass: ' + : print RED 'FAIL: '; + print $test->{name}, "\n"; } +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"; -print scalar(@results) . " tests were run\n"; -print scalar(grep $_ == 0, @results) . " PASS\n"; -print scalar(grep $_ != 0, @results) . " FAIL\n"; -exit scalar (grep $_ != 0, @results); +exit $count->('fail');