]> sjero.net Git - wget/blob - tests/run-px
"LIST" or "LIST -a" ftp command according to the remote system
[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;
8
9 die "Please specify the top source directory.\n" if (!@ARGV);
10 my $top_srcdir = shift @ARGV;
11
12 my @tests = (
13     'Test-auth-basic.px',
14     'Test-auth-no-challenge.px',
15     'Test-auth-no-challenge-url.px',
16     'Test-auth-with-content-disposition.px',
17     'Test-auth-retcode.px',
18     'Test-cookies.px',
19     'Test-cookies-401.px',
20     'Test-proxy-auth-basic.px',
21     'Test-proxied-https-auth.px',
22     'Test-N-HTTP-Content-Disposition.px',
23     'Test--spider.px',
24     'Test-c-full.px',
25     'Test-c-partial.px',
26     'Test-c-shorter.px',
27     'Test-c.px',
28     'Test-E-k-K.px',
29     'Test-E-k.px',
30     'Test-ftp.px',
31     'Test-ftp-pasv-fail.px',
32     'Test-ftp-bad-list.px',
33     'Test-ftp-recursive.px',
34     'Test-ftp-iri.px',
35     'Test-ftp-iri-fallback.px',
36     'Test-ftp-iri-recursive.px',
37     'Test-ftp-iri-disabled.px',
38     'Test-ftp-list-Multinet.px',
39     'Test-ftp-list-Unknown.px',
40     'Test-ftp-list-Unknown-a.px',
41     'Test-ftp-list-Unknown-hidden.px',
42     'Test-ftp-list-Unknown-list-a-fails.px',
43     'Test-ftp-list-UNIX-hidden.px',
44     'Test-HTTP-Content-Disposition-1.px',
45     'Test-HTTP-Content-Disposition-2.px',
46     'Test-HTTP-Content-Disposition.px',
47     'Test-i-ftp.px',
48     'Test-i-http.px',
49     'Test-idn-headers.px',
50     'Test-idn-meta.px',
51     'Test-idn-cmd.px',
52     'Test-idn-cmd-utf8.px',
53     'Test-idn-robots.px',
54     'Test-idn-robots-utf8.px',
55     'Test-iri.px',
56     'Test-iri-percent.px',
57     'Test-iri-disabled.px',
58     'Test-iri-forced-remote.px',
59     'Test-iri-list.px',
60     'Test-k.px',
61     'Test-meta-robots.px',
62     'Test-N-current.px',
63     'Test-N-smaller.px',
64     'Test-N-no-info.px',
65     'Test-N--no-content-disposition.px',
66     'Test-N--no-content-disposition-trivial.px',
67     'Test--no-content-disposition.px',
68     'Test--no-content-disposition-trivial.px',
69     'Test-N-old.px',
70     'Test-nonexisting-quiet.px',
71     'Test-noop.px',
72     'Test-np.px',
73     'Test-N.px',
74     'Test-O-HTTP-Content-Disposition.px',
75     'Test-O--no-content-disposition.px',
76     'Test-O--no-content-disposition-trivial.px',
77     'Test-O-nonexisting.px',
78     'Test-O.px',
79     'Test--post-file.px',
80     'Test-O-nc.px',
81     'Test-restrict-ascii.px',
82     'Test-Restrict-Lowercase.px',
83     'Test-Restrict-Uppercase.px',
84     'Test-stdouterr.px',
85     'Test--spider-fail.px',
86     'Test--spider-r-HTTP-Content-Disposition.px',
87     'Test--spider-r--no-content-disposition.px',
88     'Test--spider-r--no-content-disposition-trivial.px',
89     'Test--spider-r.px',
90     'Test--httpsonly-r.px',
91 );
92
93 foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
94     $ENV{$var} = '/dev/null';
95 }
96
97 my @tested;
98
99 foreach my $test (@tests) {
100     print "Running $test\n\n";
101     system("$^X -I$top_srcdir/tests $top_srcdir/tests/$test $top_srcdir");
102     push @tested, { name => $test, result => $? >> 8 };
103 }
104
105 foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
106     delete $ENV{$var};
107 }
108
109 my %exit = (
110     pass    => 0,
111     fail    => 1,
112     skip    => 2,
113     unknown => 3, # or greater
114 );
115
116 my %colors = (
117     $exit{pass}    => colored('pass:',    'green'  ),
118     $exit{fail}    => colored('FAIL:',    'red'    ),
119     $exit{skip}    => colored('Skip:',    'yellow' ),
120     $exit{unknown} => colored('Unknown:', 'magenta'),
121 );
122
123 print "\n";
124 foreach my $test (@tested) {
125     my $colored = exists $colors{$test->{result}}
126       ? $colors{$test->{result}}
127       : $colors{$exit{unknown}};
128     print "$colored $test->{name}\n";
129 }
130
131 my $count = sub
132 {
133     return {
134       pass    => sub { scalar grep $_->{result} == $exit{pass},    @tested },
135       fail    => sub { scalar grep $_->{result} == $exit{fail},    @tested },
136       skip    => sub { scalar grep $_->{result} == $exit{skip},    @tested },
137       unknown => sub { scalar grep $_->{result} >= $exit{unknown}, @tested },
138     }->{$_[0]}->();
139 };
140
141 my $summary = sub
142 {
143     my @lines = (
144         "${\scalar @tested} tests were run",
145         "${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
146         "${\$count->('skip')} SKIP, ${\$count->('unknown')} UNKNOWN",
147     );
148     my $len_longest = sub
149     {
150         local $_ = 0;
151         foreach my $line (@lines) {
152             if (length $line > $_) {
153                 $_ = length $line;
154             }
155         }
156         return $_;
157     }->();
158     return join "\n",
159       '=' x $len_longest,
160       @lines,
161       '=' x $len_longest;
162 }->();
163
164 print "\n";
165 print $count->('fail') || $count->('unknown')
166   ? colored($summary, 'red')
167   : colored($summary, 'green');
168 print "\n";
169
170 exit $count->('fail') + $count->('unknown');