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