2008-05-23 14:14:05 +08:00
|
|
|
#!/usr/bin/env perl
|
2008-11-08 05:06:38 +08:00
|
|
|
|
|
|
|
use 5.006;
|
2008-11-07 03:38:16 +08:00
|
|
|
use strict;
|
2008-11-13 05:54:49 +08:00
|
|
|
use warnings;
|
2008-05-23 14:14:05 +08:00
|
|
|
|
2008-11-08 05:06:38 +08:00
|
|
|
use Term::ANSIColor ':constants';
|
|
|
|
$Term::ANSIColor::AUTORESET = 1;
|
|
|
|
|
2008-05-23 14:14:05 +08:00
|
|
|
die "Please specify the top source directory.\n" if (!@ARGV);
|
|
|
|
my $top_srcdir = shift @ARGV;
|
|
|
|
|
|
|
|
my @tests = (
|
|
|
|
'Test-auth-basic.px',
|
2008-11-12 04:53:01 +08:00
|
|
|
'Test-auth-no-challenge.px',
|
|
|
|
'Test-auth-no-challenge-url.px',
|
2009-08-27 15:40:48 +08:00
|
|
|
'Test-cookies.px',
|
|
|
|
'Test-cookies-401.px',
|
2008-05-23 14:59:28 +08:00
|
|
|
'Test-proxy-auth-basic.px',
|
|
|
|
'Test-proxied-https-auth.px',
|
|
|
|
'Test-N-HTTP-Content-Disposition.px',
|
2008-05-23 15:04:09 +08:00
|
|
|
'Test--spider.px',
|
2008-05-23 14:14:05 +08:00
|
|
|
'Test-c-full.px',
|
|
|
|
'Test-c-partial.px',
|
2008-08-23 08:39:47 +08:00
|
|
|
'Test-c-shorter.px',
|
2008-05-23 14:14:05 +08:00
|
|
|
'Test-c.px',
|
|
|
|
'Test-E-k-K.px',
|
|
|
|
'Test-E-k.px',
|
|
|
|
'Test-ftp.px',
|
2008-08-02 19:47:10 +08:00
|
|
|
'Test-ftp-iri.px',
|
|
|
|
'Test-ftp-iri-fallback.px',
|
2009-06-30 09:53:13 +08:00
|
|
|
'Test-ftp-iri-recursive.px',
|
2008-08-02 19:47:10 +08:00
|
|
|
'Test-ftp-iri-disabled.px',
|
2008-05-23 14:14:05 +08:00
|
|
|
'Test-HTTP-Content-Disposition-1.px',
|
|
|
|
'Test-HTTP-Content-Disposition-2.px',
|
|
|
|
'Test-HTTP-Content-Disposition.px',
|
2008-08-28 17:45:29 +08:00
|
|
|
'Test-idn-headers.px',
|
2008-08-29 03:47:17 +08:00
|
|
|
'Test-idn-meta.px',
|
2008-09-10 12:55:02 +08:00
|
|
|
'Test-idn-cmd.px',
|
2008-12-05 06:25:12 +08:00
|
|
|
'Test-idn-robots.px',
|
2008-08-02 18:17:03 +08:00
|
|
|
'Test-iri.px',
|
2009-06-29 18:29:16 +08:00
|
|
|
'Test-iri-percent.px',
|
2008-08-02 18:17:03 +08:00
|
|
|
'Test-iri-disabled.px',
|
|
|
|
'Test-iri-forced-remote.px',
|
2008-08-15 00:26:53 +08:00
|
|
|
'Test-iri-list.px',
|
2009-07-06 14:23:17 +08:00
|
|
|
'Test-meta-robots.px',
|
2008-05-23 14:14:05 +08:00
|
|
|
'Test-N-current.px',
|
2008-06-01 04:22:15 +08:00
|
|
|
'Test-N-smaller.px',
|
2008-06-01 04:31:05 +08:00
|
|
|
'Test-N-no-info.px',
|
2008-05-23 14:14:05 +08:00
|
|
|
'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',
|
2008-08-23 07:56:18 +08:00
|
|
|
'Test-O-nc.px',
|
2009-07-28 14:41:26 +08:00
|
|
|
'Test-restrict-ascii.px',
|
2008-05-23 14:14:05 +08:00
|
|
|
'Test-Restrict-Lowercase.px',
|
|
|
|
'Test-Restrict-Uppercase.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',
|
|
|
|
);
|
|
|
|
|
2009-04-12 03:59:55 +08:00
|
|
|
foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
|
|
|
|
$ENV{$var} = '/dev/null';
|
|
|
|
}
|
|
|
|
|
2008-11-08 05:06:38 +08:00
|
|
|
my @tested;
|
2008-05-23 14:14:05 +08:00
|
|
|
|
2008-11-08 05:06:38 +08:00
|
|
|
foreach my $test (@tests) {
|
2008-05-23 14:14:05 +08:00
|
|
|
print "Running $test\n\n";
|
2009-06-12 15:06:10 +08:00
|
|
|
system("$^X -I$top_srcdir/tests $top_srcdir/tests/$test $top_srcdir");
|
2008-11-08 05:06:38 +08:00
|
|
|
push @tested, { name => $test, result => $? };
|
2008-05-23 14:14:05 +08:00
|
|
|
}
|
|
|
|
|
2009-04-12 03:59:55 +08:00
|
|
|
foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
|
|
|
|
delete $ENV{$var};
|
|
|
|
}
|
|
|
|
|
2008-11-08 05:06:38 +08:00
|
|
|
print "\n";
|
|
|
|
foreach my $test (@tested) {
|
|
|
|
($test->{result} == 0)
|
|
|
|
? print GREEN 'pass: '
|
|
|
|
: print RED 'FAIL: ';
|
|
|
|
print $test->{name}, "\n";
|
2008-05-23 14:14:05 +08:00
|
|
|
}
|
2008-06-13 06:21:32 +08:00
|
|
|
|
2008-11-08 05:06:38 +08:00
|
|
|
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;
|
2008-06-13 06:21:32 +08:00
|
|
|
print "\n";
|
|
|
|
|
2008-11-08 05:06:38 +08:00
|
|
|
exit $count->('fail');
|