]> sjero.net Git - wget/blob - tests/run-px
More module-scoped warnings.
[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-proxy-auth-basic.px',
18     'Test-proxied-https-auth.px',
19     'Test-N-HTTP-Content-Disposition.px',
20     'Test--spider.px',
21     'Test-c-full.px',
22     'Test-c-partial.px',
23     'Test-c-shorter.px',
24     'Test-c.px',
25     'Test-E-k-K.px',
26     'Test-E-k.px',
27     'Test-ftp.px',
28     'Test-ftp-iri.px',
29     'Test-ftp-iri-fallback.px',
30     'Test-ftp-iri-disabled.px',
31     'Test-HTTP-Content-Disposition-1.px',
32     'Test-HTTP-Content-Disposition-2.px',
33     'Test-HTTP-Content-Disposition.px',
34     'Test-idn-headers.px',
35     'Test-idn-meta.px',
36     'Test-idn-cmd.px',
37     'Test-iri.px',
38     'Test-iri-disabled.px',
39     'Test-iri-forced-remote.px',
40     'Test-iri-list.px',
41     'Test-N-current.px',
42     'Test-N-smaller.px',
43     'Test-N-no-info.px',
44     'Test-N--no-content-disposition.px',
45     'Test-N--no-content-disposition-trivial.px',
46     'Test--no-content-disposition.px',
47     'Test--no-content-disposition-trivial.px',
48     'Test-N-old.px',
49     'Test-nonexisting-quiet.px',
50     'Test-noop.px',
51     'Test-np.px',
52     'Test-N.px',
53     'Test-O-HTTP-Content-Disposition.px',
54     'Test-O--no-content-disposition.px',
55     'Test-O--no-content-disposition-trivial.px',
56     'Test-O-nonexisting.px',
57     'Test-O.px',
58     'Test-O-nc.px',
59     'Test-Restrict-Lowercase.px',
60     'Test-Restrict-Uppercase.px',
61     'Test--spider-fail.px',
62     'Test--spider-r-HTTP-Content-Disposition.px',
63     'Test--spider-r--no-content-disposition.px',
64     'Test--spider-r--no-content-disposition-trivial.px',
65     'Test--spider-r.px',
66 );
67
68 my @tested;
69
70 foreach my $test (@tests) {
71     print "Running $test\n\n";
72     system("$^X $top_srcdir/tests/$test");
73     push @tested, { name => $test, result => $? };
74 }
75
76 print "\n";
77 foreach my $test (@tested) {
78     ($test->{result} == 0)
79       ? print GREEN 'pass: '
80       : print RED 'FAIL: ';
81    print $test->{name}, "\n";
82 }
83
84 my $count = sub
85 {
86     return {
87       pass => sub { scalar grep $_->{result} == 0, @tested },
88       fail => sub { scalar grep $_->{result} != 0, @tested },
89     }->{$_[0]}->();
90 };
91
92 my $summary = sub
93 {
94     my @lines = (
95         "${\scalar @tested} tests were run",
96         "${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
97     );
98     my $len_longest = sub
99     {
100         local $_ = 0;
101         foreach my $line (@lines) {
102             if (length $line > $_) {
103                 $_ = length $line;
104             }
105         }
106         return $_;
107     }->();
108     return join "\n",
109       '=' x $len_longest,
110       @lines,
111       '=' x $len_longest;
112 }->();
113
114 print "\n";
115 print $count->('fail')
116   ? RED $summary
117   : GREEN $summary;
118 print "\n";
119
120 exit $count->('fail');