]> sjero.net Git - wget/blobdiff - tests/run-px
Attempted, but failed, to reproduce bug 22403.
[wget] / tests / run-px
index 6fe0d9fbb7532dbb06c1854788c50e9691b950ff..1a441c7b843836ae41c72249c6e3860f2c016b70 100755 (executable)
@@ -4,8 +4,7 @@ use 5.006;
 use strict;
 use warnings;
 
-use Term::ANSIColor ':constants';
-$Term::ANSIColor::AUTORESET = 1;
+use Term::ANSIColor;
 
 die "Please specify the top source directory.\n" if (!@ARGV);
 my $top_srcdir = shift @ARGV;
@@ -14,6 +13,8 @@ my @tests = (
     'Test-auth-basic.px',
     'Test-auth-no-challenge.px',
     'Test-auth-no-challenge-url.px',
+    'Test-cookies.px',
+    'Test-cookies-401.px',
     'Test-proxy-auth-basic.px',
     'Test-proxied-https-auth.px',
     'Test-N-HTTP-Content-Disposition.px',
@@ -25,9 +26,27 @@ my @tests = (
     'Test-E-k-K.px',
     'Test-E-k.px',
     'Test-ftp.px',
+    'Test-ftp-pasv-fail.px',
+    'Test-ftp-bad-list.px',
+    'Test-ftp-recursive.px',
+    'Test-ftp-iri.px',
+    'Test-ftp-iri-fallback.px',
+    'Test-ftp-iri-recursive.px',
+    'Test-ftp-iri-disabled.px',
     'Test-HTTP-Content-Disposition-1.px',
     'Test-HTTP-Content-Disposition-2.px',
     'Test-HTTP-Content-Disposition.px',
+    'Test-idn-headers.px',
+    'Test-idn-meta.px',
+    'Test-idn-cmd.px',
+    'Test-idn-robots.px',
+    'Test-iri.px',
+    'Test-iri-percent.px',
+    'Test-iri-disabled.px',
+    'Test-iri-forced-remote.px',
+    'Test-iri-list.px',
+    'Test-k.px',
+    'Test-meta-robots.px',
     'Test-N-current.px',
     'Test-N-smaller.px',
     'Test-N-no-info.px',
@@ -46,6 +65,7 @@ my @tests = (
     'Test-O-nonexisting.px',
     'Test-O.px',
     'Test-O-nc.px',
+    'Test-restrict-ascii.px',
     'Test-Restrict-Lowercase.px',
     'Test-Restrict-Uppercase.px',
     'Test--spider-fail.px',
@@ -55,27 +75,51 @@ my @tests = (
     'Test--spider-r.px',
 );
 
+foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
+    $ENV{$var} = '/dev/null';
+}
+
 my @tested;
 
 foreach my $test (@tests) {
     print "Running $test\n\n";
-    system("$^X -I$top_srcdir/tests $top_srcdir/tests/$test");
-    push @tested, { name => $test, result => $? };
+    system("$^X -I$top_srcdir/tests $top_srcdir/tests/$test $top_srcdir");
+    push @tested, { name => $test, result => $? >> 8 };
+}
+
+foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
+    delete $ENV{$var};
 }
 
+my %exit = (
+    pass    => 0,
+    fail    => 1,
+    skip    => 2,
+    unknown => 3, # or greater
+);
+
+my %colors = (
+    $exit{pass}    => colored('pass:',    'green'  ),
+    $exit{fail}    => colored('FAIL:',    'red'    ),
+    $exit{skip}    => colored('Skip:',    'yellow' ),
+    $exit{unknown} => colored('Unknown:', 'magenta'),
+);
+
 print "\n";
 foreach my $test (@tested) {
-    ($test->{result} == 0)
-      ? print GREEN 'pass: '
-      : print RED 'FAIL: ';
-   print $test->{name}, "\n";
+    my $colored = exists $colors{$test->{result}}
+      ? $colors{$test->{result}}
+      : $colors{$exit{unknown}};
+    print "$colored $test->{name}\n";
 }
 
 my $count = sub
 {
     return {
-      pass => sub { scalar grep $_->{result} == 0, @tested },
-      fail => sub { scalar grep $_->{result} != 0, @tested },
+      pass    => sub { scalar grep $_->{result} == $exit{pass},    @tested },
+      fail    => sub { scalar grep $_->{result} == $exit{fail},    @tested },
+      skip    => sub { scalar grep $_->{result} == $exit{skip},    @tested },
+      unknown => sub { scalar grep $_->{result} >= $exit{unknown}, @tested },
     }->{$_[0]}->();
 };
 
@@ -84,6 +128,7 @@ my $summary = sub
     my @lines = (
         "${\scalar @tested} tests were run",
         "${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
+        "${\$count->('skip')} SKIP, ${\$count->('unknown')} UNKNOWN",
     );
     my $len_longest = sub
     {
@@ -103,8 +148,8 @@ my $summary = sub
 
 print "\n";
 print $count->('fail')
-  ? RED $summary
-  : GREEN $summary;
+  ? colored($summary, 'red')
+  : colored($summary, 'green');
 print "\n";
 
 exit $count->('fail');