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