]> sjero.net Git - wget/blob - tests/run-px
b480f1416c82a72977e4876b4d1c64c346df82cd
[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-recursive.px',
31     'Test-ftp-iri-disabled.px',
32     'Test-HTTP-Content-Disposition-1.px',
33     'Test-HTTP-Content-Disposition-2.px',
34     'Test-HTTP-Content-Disposition.px',
35     'Test-idn-headers.px',
36     'Test-idn-meta.px',
37     'Test-idn-cmd.px',
38     'Test-idn-robots.px',
39     'Test-iri.px',
40     'Test-iri-percent.px',
41     'Test-iri-disabled.px',
42     'Test-iri-forced-remote.px',
43     'Test-iri-list.px',
44     'Test-meta-robots.px',
45     'Test-N-current.px',
46     'Test-N-smaller.px',
47     'Test-N-no-info.px',
48     'Test-N--no-content-disposition.px',
49     'Test-N--no-content-disposition-trivial.px',
50     'Test--no-content-disposition.px',
51     'Test--no-content-disposition-trivial.px',
52     'Test-N-old.px',
53     'Test-nonexisting-quiet.px',
54     'Test-noop.px',
55     'Test-np.px',
56     'Test-N.px',
57     'Test-O-HTTP-Content-Disposition.px',
58     'Test-O--no-content-disposition.px',
59     'Test-O--no-content-disposition-trivial.px',
60     'Test-O-nonexisting.px',
61     'Test-O.px',
62     'Test-O-nc.px',
63     'Test-Restrict-Lowercase.px',
64     'Test-Restrict-Uppercase.px',
65     'Test--spider-fail.px',
66     'Test--spider-r-HTTP-Content-Disposition.px',
67     'Test--spider-r--no-content-disposition.px',
68     'Test--spider-r--no-content-disposition-trivial.px',
69     'Test--spider-r.px',
70 );
71
72 foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
73     $ENV{$var} = '/dev/null';
74 }
75
76 my @tested;
77
78 foreach my $test (@tests) {
79     print "Running $test\n\n";
80     system("$^X -I$top_srcdir/tests $top_srcdir/tests/$test $top_srcdir");
81     push @tested, { name => $test, result => $? };
82 }
83
84 foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
85     delete $ENV{$var};
86 }
87
88 print "\n";
89 foreach my $test (@tested) {
90     ($test->{result} == 0)
91       ? print GREEN 'pass: '
92       : print RED 'FAIL: ';
93    print $test->{name}, "\n";
94 }
95
96 my $count = sub
97 {
98     return {
99       pass => sub { scalar grep $_->{result} == 0, @tested },
100       fail => sub { scalar grep $_->{result} != 0, @tested },
101     }->{$_[0]}->();
102 };
103
104 my $summary = sub
105 {
106     my @lines = (
107         "${\scalar @tested} tests were run",
108         "${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
109     );
110     my $len_longest = sub
111     {
112         local $_ = 0;
113         foreach my $line (@lines) {
114             if (length $line > $_) {
115                 $_ = length $line;
116             }
117         }
118         return $_;
119     }->();
120     return join "\n",
121       '=' x $len_longest,
122       @lines,
123       '=' x $len_longest;
124 }->();
125
126 print "\n";
127 print $count->('fail')
128   ? RED $summary
129   : GREEN $summary;
130 print "\n";
131
132 exit $count->('fail');