]> sjero.net Git - wget/blob - tests/run-px
Rewrote FTPServer.pm to avoid filesystem; added Test-ftp-recursive.px.
[wget] / tests / run-px
1 #!/usr/bin/env perl
2
3 use 5.006;
4 use strict;
5 use warnings;
6
7 use Term::ANSIColor ':constants';
8 $Term::ANSIColor::AUTORESET = 1;
9
10 die "Please specify the top source directory.\n" if (!@ARGV);
11 my $top_srcdir = shift @ARGV;
12
13 my @tests = (
14     'Test-auth-basic.px',
15     'Test-auth-no-challenge.px',
16     'Test-auth-no-challenge-url.px',
17     'Test-cookies.px',
18     'Test-cookies-401.px',
19     'Test-proxy-auth-basic.px',
20     'Test-proxied-https-auth.px',
21     'Test-N-HTTP-Content-Disposition.px',
22     'Test--spider.px',
23     'Test-c-full.px',
24     'Test-c-partial.px',
25     'Test-c-shorter.px',
26     'Test-c.px',
27     'Test-E-k-K.px',
28     'Test-E-k.px',
29     'Test-ftp.px',
30     'Test-ftp-recursive.px',
31     'Test-ftp-iri.px',
32     'Test-ftp-iri-fallback.px',
33     'Test-ftp-iri-recursive.px',
34     'Test-ftp-iri-disabled.px',
35     'Test-HTTP-Content-Disposition-1.px',
36     'Test-HTTP-Content-Disposition-2.px',
37     'Test-HTTP-Content-Disposition.px',
38     'Test-idn-headers.px',
39     'Test-idn-meta.px',
40     'Test-idn-cmd.px',
41     'Test-idn-robots.px',
42     'Test-iri.px',
43     'Test-iri-percent.px',
44     'Test-iri-disabled.px',
45     'Test-iri-forced-remote.px',
46     'Test-iri-list.px',
47     'Test-k.px',
48     'Test-meta-robots.px',
49     'Test-N-current.px',
50     'Test-N-smaller.px',
51     'Test-N-no-info.px',
52     'Test-N--no-content-disposition.px',
53     'Test-N--no-content-disposition-trivial.px',
54     'Test--no-content-disposition.px',
55     'Test--no-content-disposition-trivial.px',
56     'Test-N-old.px',
57     'Test-nonexisting-quiet.px',
58     'Test-noop.px',
59     'Test-np.px',
60     'Test-N.px',
61     'Test-O-HTTP-Content-Disposition.px',
62     'Test-O--no-content-disposition.px',
63     'Test-O--no-content-disposition-trivial.px',
64     'Test-O-nonexisting.px',
65     'Test-O.px',
66     'Test-O-nc.px',
67     'Test-restrict-ascii.px',
68     'Test-Restrict-Lowercase.px',
69     'Test-Restrict-Uppercase.px',
70     'Test--spider-fail.px',
71     'Test--spider-r-HTTP-Content-Disposition.px',
72     'Test--spider-r--no-content-disposition.px',
73     'Test--spider-r--no-content-disposition-trivial.px',
74     'Test--spider-r.px',
75 );
76
77 foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
78     $ENV{$var} = '/dev/null';
79 }
80
81 my @tested;
82
83 foreach my $test (@tests) {
84     print "Running $test\n\n";
85     system("$^X -I$top_srcdir/tests $top_srcdir/tests/$test $top_srcdir");
86     push @tested, { name => $test, result => $? };
87 }
88
89 foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
90     delete $ENV{$var};
91 }
92
93 print "\n";
94 foreach my $test (@tested) {
95     ($test->{result} == 0)
96       ? print GREEN 'pass: '
97       : print RED 'FAIL: ';
98    print $test->{name}, "\n";
99 }
100
101 my $count = sub
102 {
103     return {
104       pass => sub { scalar grep $_->{result} == 0, @tested },
105       fail => sub { scalar grep $_->{result} != 0, @tested },
106     }->{$_[0]}->();
107 };
108
109 my $summary = sub
110 {
111     my @lines = (
112         "${\scalar @tested} tests were run",
113         "${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
114     );
115     my $len_longest = sub
116     {
117         local $_ = 0;
118         foreach my $line (@lines) {
119             if (length $line > $_) {
120                 $_ = length $line;
121             }
122         }
123         return $_;
124     }->();
125     return join "\n",
126       '=' x $len_longest,
127       @lines,
128       '=' x $len_longest;
129 }->();
130
131 print "\n";
132 print $count->('fail')
133   ? RED $summary
134   : GREEN $summary;
135 print "\n";
136
137 exit $count->('fail');