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