X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=tests%2Frun-px;h=92e9061e0694645e3e3474dfbe07e80fff19647d;hb=7fc928183366c256ef4c425c19ea2f054d68aafd;hp=fd1c40acdadbdf39a9ff1a4aeb1816fa278de716;hpb=6ed6093dfcdfbae6f74ef96763200e5523cfb0df;p=wget diff --git a/tests/run-px b/tests/run-px index fd1c40ac..92e9061e 100755 --- a/tests/run-px +++ b/tests/run-px @@ -1,5 +1,11 @@ #!/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; @@ -10,9 +16,9 @@ my @tests = ( 'Test-proxied-https-auth.px', 'Test-N-HTTP-Content-Disposition.px', 'Test--spider.px', - 'Test-c-full.px', 'Test-c-partial.px', + 'Test-c-shorter.px', 'Test-c.px', 'Test-E-k-K.px', 'Test-E-k.px', @@ -21,6 +27,8 @@ my @tests = ( 'Test-HTTP-Content-Disposition-2.px', 'Test-HTTP-Content-Disposition.px', 'Test-N-current.px', + 'Test-N-smaller.px', + 'Test-N-no-info.px', 'Test-N--no-content-disposition.px', 'Test-N--no-content-disposition-trivial.px', 'Test--no-content-disposition.px', @@ -35,6 +43,7 @@ my @tests = ( 'Test-O--no-content-disposition-trivial.px', 'Test-O-nonexisting.px', 'Test-O.px', + 'Test-O-nc.px', 'Test-Restrict-Lowercase.px', 'Test-Restrict-Uppercase.px', 'Test--spider-fail.px', @@ -44,19 +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("$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"; + +exit $count->('fail');