]> sjero.net Git - wget/blob - tests/run-px
Use lexical warnings in test scripts.
[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-HTTP-Content-Disposition-1.px',
29     'Test-HTTP-Content-Disposition-2.px',
30     'Test-HTTP-Content-Disposition.px',
31     'Test-N-current.px',
32     'Test-N-smaller.px',
33     'Test-N-no-info.px',
34     'Test-N--no-content-disposition.px',
35     'Test-N--no-content-disposition-trivial.px',
36     'Test--no-content-disposition.px',
37     'Test--no-content-disposition-trivial.px',
38     'Test-N-old.px',
39     'Test-nonexisting-quiet.px',
40     'Test-noop.px',
41     'Test-np.px',
42     'Test-N.px',
43     'Test-O-HTTP-Content-Disposition.px',
44     'Test-O--no-content-disposition.px',
45     'Test-O--no-content-disposition-trivial.px',
46     'Test-O-nonexisting.px',
47     'Test-O.px',
48     'Test-O-nc.px',
49     'Test-Restrict-Lowercase.px',
50     'Test-Restrict-Uppercase.px',
51     'Test--spider-fail.px',
52     'Test--spider-r-HTTP-Content-Disposition.px',
53     'Test--spider-r--no-content-disposition.px',
54     'Test--spider-r--no-content-disposition-trivial.px',
55     'Test--spider-r.px',
56 );
57
58 my @tested;
59
60 foreach my $test (@tests) {
61     print "Running $test\n\n";
62     system("$^X $top_srcdir/tests/$test");
63     push @tested, { name => $test, result => $? };
64 }
65
66 print "\n";
67 foreach my $test (@tested) {
68     ($test->{result} == 0)
69       ? print GREEN 'pass: '
70       : print RED 'FAIL: ';
71    print $test->{name}, "\n";
72 }
73
74 my $count = sub
75 {
76     return {
77       pass => sub { scalar grep $_->{result} == 0, @tested },
78       fail => sub { scalar grep $_->{result} != 0, @tested },
79     }->{$_[0]}->();
80 };
81
82 my $summary = sub
83 {
84     my @lines = (
85         "${\scalar @tested} tests were run",
86         "${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
87     );
88     my $len_longest = sub
89     {
90         local $_ = 0;
91         foreach my $line (@lines) {
92             if (length $line > $_) {
93                 $_ = length $line;
94             }
95         }
96         return $_;
97     }->();
98     return join "\n",
99       '=' x $len_longest,
100       @lines,
101       '=' x $len_longest;
102 }->();
103
104 print "\n";
105 print $count->('fail')
106   ? RED $summary
107   : GREEN $summary;
108 print "\n";
109
110 exit $count->('fail');