]> sjero.net Git - wget/blob - tests/run-px
Updated config.guess, config.sub, install.sh.
[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-ascii.px',
64     'Test-Restrict-Lowercase.px',
65     'Test-Restrict-Uppercase.px',
66     'Test--spider-fail.px',
67     'Test--spider-r-HTTP-Content-Disposition.px',
68     'Test--spider-r--no-content-disposition.px',
69     'Test--spider-r--no-content-disposition-trivial.px',
70     'Test--spider-r.px',
71 );
72
73 foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
74     $ENV{$var} = '/dev/null';
75 }
76
77 my @tested;
78
79 foreach my $test (@tests) {
80     print "Running $test\n\n";
81     system("$^X -I$top_srcdir/tests $top_srcdir/tests/$test $top_srcdir");
82     push @tested, { name => $test, result => $? };
83 }
84
85 foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
86     delete $ENV{$var};
87 }
88
89 print "\n";
90 foreach my $test (@tested) {
91     ($test->{result} == 0)
92       ? print GREEN 'pass: '
93       : print RED 'FAIL: ';
94    print $test->{name}, "\n";
95 }
96
97 my $count = sub
98 {
99     return {
100       pass => sub { scalar grep $_->{result} == 0, @tested },
101       fail => sub { scalar grep $_->{result} != 0, @tested },
102     }->{$_[0]}->();
103 };
104
105 my $summary = sub
106 {
107     my @lines = (
108         "${\scalar @tested} tests were run",
109         "${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
110     );
111     my $len_longest = sub
112     {
113         local $_ = 0;
114         foreach my $line (@lines) {
115             if (length $line > $_) {
116                 $_ = length $line;
117             }
118         }
119         return $_;
120     }->();
121     return join "\n",
122       '=' x $len_longest,
123       @lines,
124       '=' x $len_longest;
125 }->();
126
127 print "\n";
128 print $count->('fail')
129   ? RED $summary
130   : GREEN $summary;
131 print "\n";
132
133 exit $count->('fail');