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