1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00
wget/tests/run-px

171 lines
4.4 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env perl
2008-11-07 16:06:38 -05:00
use 5.006;
2008-11-06 14:38:16 -05:00
use strict;
2008-11-12 16:54:49 -05:00
use warnings;
use Term::ANSIColor;
2008-11-07 16:06:38 -05:00
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-auth-with-content-disposition.px',
2010-05-29 17:10:59 -04:00
'Test-auth-retcode.px',
2009-08-27 03:40:48 -04:00
'Test-cookies.px',
'Test-cookies-401.px',
'Test-proxy-auth-basic.px',
'Test-proxied-https-auth.px',
'Test-N-HTTP-Content-Disposition.px',
'Test--spider.px',
'Test-c-full.px',
'Test-c-partial.px',
2008-08-22 20:39:47 -04:00
'Test-c-shorter.px',
'Test-c.px',
'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',
2008-08-02 07:47:10 -04:00
'Test-ftp-iri.px',
'Test-ftp-iri-fallback.px',
2009-06-29 21:53:13 -04:00
'Test-ftp-iri-recursive.px',
2008-08-02 07:47:10 -04:00
'Test-ftp-iri-disabled.px',
'Test-ftp-list-Multinet.px',
'Test-ftp-list-Unknown.px',
'Test-ftp-list-Unknown-a.px',
'Test-ftp-list-Unknown-hidden.px',
'Test-ftp-list-Unknown-list-a-fails.px',
'Test-ftp-list-UNIX-hidden.px',
'Test-HTTP-Content-Disposition-1.px',
'Test-HTTP-Content-Disposition-2.px',
'Test-HTTP-Content-Disposition.px',
2010-03-01 18:00:17 -05:00
'Test-i-ftp.px',
2010-02-26 17:07:51 -05:00
'Test-i-http.px',
2008-08-28 05:45:29 -04:00
'Test-idn-headers.px',
'Test-idn-meta.px',
2008-09-10 00:55:02 -04:00
'Test-idn-cmd.px',
'Test-idn-cmd-utf8.px',
2008-12-04 17:25:12 -05:00
'Test-idn-robots.px',
'Test-idn-robots-utf8.px',
2008-08-02 06:17:03 -04:00
'Test-iri.px',
2009-06-29 06:29:16 -04:00
'Test-iri-percent.px',
2008-08-02 06:17:03 -04:00
'Test-iri-disabled.px',
'Test-iri-forced-remote.px',
'Test-iri-list.px',
'Test-k.px',
2009-07-06 02:23:17 -04:00
'Test-meta-robots.px',
'Test-N-current.px',
2008-05-31 16:22:15 -04:00
'Test-N-smaller.px',
2008-05-31 16:31:05 -04:00
'Test-N-no-info.px',
'Test-N--no-content-disposition.px',
'Test-N--no-content-disposition-trivial.px',
'Test--no-content-disposition.px',
'Test--no-content-disposition-trivial.px',
'Test-N-old.px',
'Test-nonexisting-quiet.px',
'Test-noop.px',
'Test-np.px',
'Test-N.px',
'Test-O-HTTP-Content-Disposition.px',
'Test-O--no-content-disposition.px',
'Test-O--no-content-disposition-trivial.px',
'Test-O-nonexisting.px',
'Test-O.px',
'Test--post-file.px',
2008-08-22 19:56:18 -04:00
'Test-O-nc.px',
2009-07-28 02:41:26 -04:00
'Test-restrict-ascii.px',
'Test-Restrict-Lowercase.px',
'Test-Restrict-Uppercase.px',
2012-06-16 07:05:03 -04:00
'Test-stdouterr.px',
'Test--spider-fail.px',
'Test--spider-r-HTTP-Content-Disposition.px',
'Test--spider-r--no-content-disposition.px',
'Test--spider-r--no-content-disposition-trivial.px',
'Test--spider-r.px',
2013-08-22 06:28:11 -04:00
'Test--httpsonly-r.px',
);
foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
$ENV{$var} = '/dev/null';
}
2008-11-07 16:06:38 -05:00
my @tested;
2008-11-07 16:06:38 -05:00
foreach my $test (@tests) {
print "Running $test\n\n";
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'),
);
2008-11-07 16:06:38 -05:00
print "\n";
foreach my $test (@tested) {
my $colored = exists $colors{$test->{result}}
? $colors{$test->{result}}
: $colors{$exit{unknown}};
print "$colored $test->{name}\n";
}
2008-06-12 18:21:32 -04:00
2008-11-07 16:06:38 -05:00
my $count = sub
{
return {
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 },
2008-11-07 16:06:38 -05:00
}->{$_[0]}->();
};
my $summary = sub
{
my @lines = (
"${\scalar @tested} tests were run",
"${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
"${\$count->('skip')} SKIP, ${\$count->('unknown')} UNKNOWN",
2008-11-07 16:06:38 -05:00
);
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') || $count->('unknown')
? colored($summary, 'red')
: colored($summary, 'green');
2008-06-12 18:21:32 -04:00
print "\n";
exit $count->('fail') + $count->('unknown');