mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Enhance tests to include feature checking.
This commit is contained in:
parent
0c24c435e7
commit
986cfac8d5
@ -1,3 +1,26 @@
|
|||||||
|
2009-09-05 Steven Schubiger <stsc@member.fsf.org>
|
||||||
|
|
||||||
|
* run-px: Introduce two new diagnostics: Skip and Unknown.
|
||||||
|
|
||||||
|
* WgetFeature.pm (import): Parse the version output of Wget
|
||||||
|
and assert the availability of a feature.
|
||||||
|
|
||||||
|
* WgetFeature.cfg: Messages to be printed in absence of a
|
||||||
|
required feature.
|
||||||
|
|
||||||
|
* Test-ftp-iri-disabled.px, Test-ftp-iri-fallback.px,
|
||||||
|
Test-ftp-iri-recursive.px, Test-ftp-iri.px, Test-idn-cmd.px,
|
||||||
|
Test-idn-headers.px, Test-idn-meta.px, Test-idn-robots.px,
|
||||||
|
Test-iri-forced-remote.px, Test-iri-list.px,
|
||||||
|
Test-iri-percent.px, Test-iri.px: Use WgetFeature.pm to
|
||||||
|
check for the presence of the IDN/IRI feature.
|
||||||
|
|
||||||
|
* Test-proxied-https-auth.px: Replace grepping for a feature
|
||||||
|
with loading WgetFeature.pm at compile-time.
|
||||||
|
|
||||||
|
* Makefile.am: Add WgetFeature.pm and WgetFeature.cfg
|
||||||
|
to EXTRA_DIST.
|
||||||
|
|
||||||
2009-09-02 Micah Cowan <micah@cowan.name>
|
2009-09-02 Micah Cowan <micah@cowan.name>
|
||||||
|
|
||||||
* Makefile.am (unit-tests): explicit dependency is
|
* Makefile.am (unit-tests): explicit dependency is
|
||||||
|
@ -60,6 +60,7 @@ run-px-tests: WgetTest.pm ../src/wget$(EXEEXT)
|
|||||||
$(srcdir)/run-px $(top_srcdir)
|
$(srcdir)/run-px $(top_srcdir)
|
||||||
|
|
||||||
EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
|
EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
|
||||||
|
WgetFeature.pm WgetFeature.cfg \
|
||||||
Test-auth-basic.px \
|
Test-auth-basic.px \
|
||||||
Test-auth-no-challenge.px \
|
Test-auth-no-challenge.px \
|
||||||
Test-auth-no-challenge-url.px \
|
Test-auth-no-challenge-url.px \
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(iri);
|
||||||
use FTPTest;
|
use FTPTest;
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(iri);
|
||||||
use FTPTest;
|
use FTPTest;
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(iri);
|
||||||
use FTPTest;
|
use FTPTest;
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(iri);
|
||||||
use FTPTest;
|
use FTPTest;
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(iri);
|
||||||
use HTTPTest;
|
use HTTPTest;
|
||||||
|
|
||||||
# " Kon'nichiwa <dot> Japan
|
# " Kon'nichiwa <dot> Japan
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(iri);
|
||||||
use HTTPTest;
|
use HTTPTest;
|
||||||
|
|
||||||
# " Kon'nichiwa <dot> Japan
|
# " Kon'nichiwa <dot> Japan
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(iri);
|
||||||
use HTTPTest;
|
use HTTPTest;
|
||||||
|
|
||||||
# " Kon'nichiwa <dot> Japan
|
# " Kon'nichiwa <dot> Japan
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(iri);
|
||||||
use HTTPTest;
|
use HTTPTest;
|
||||||
|
|
||||||
# " Kon'nichiwa <dot> Japan
|
# " Kon'nichiwa <dot> Japan
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(iri);
|
||||||
use HTTPTest;
|
use HTTPTest;
|
||||||
|
|
||||||
# cf. http://en.wikipedia.org/wiki/Latin1
|
# cf. http://en.wikipedia.org/wiki/Latin1
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(iri);
|
||||||
use HTTPTest;
|
use HTTPTest;
|
||||||
|
|
||||||
# cf. http://en.wikipedia.org/wiki/Latin1
|
# cf. http://en.wikipedia.org/wiki/Latin1
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(iri);
|
||||||
use HTTPTest;
|
use HTTPTest;
|
||||||
|
|
||||||
# Just a sanity check to verify that %-encoded values are always left
|
# Just a sanity check to verify that %-encoded values are always left
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(iri);
|
||||||
use HTTPTest;
|
use HTTPTest;
|
||||||
|
|
||||||
# cf. http://en.wikipedia.org/wiki/Latin1
|
# cf. http://en.wikipedia.org/wiki/Latin1
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use WgetFeature qw(https);
|
||||||
use WgetTest; # For $WGETPATH.
|
use WgetTest; # For $WGETPATH.
|
||||||
|
|
||||||
my $cert_path;
|
my $cert_path;
|
||||||
@ -14,15 +15,6 @@ if (@ARGV) {
|
|||||||
$cert_path = "$top_srcdir/tests/certs/server-cert.pem";
|
$cert_path = "$top_srcdir/tests/certs/server-cert.pem";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Have we even built an HTTPS-supporting Wget?
|
|
||||||
{
|
|
||||||
my @version_lines = `${WgetTest::WGETPATH} --version`;
|
|
||||||
unless (grep /\+(openssl|gnutls)/, @version_lines) {
|
|
||||||
print "Not running test: Wget under test doesn't support HTTPS.\n";
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
use HTTP::Daemon;
|
use HTTP::Daemon;
|
||||||
use HTTP::Request;
|
use HTTP::Request;
|
||||||
use IO::Socket::SSL;
|
use IO::Socket::SSL;
|
||||||
|
6
tests/WgetFeature.cfg
Normal file
6
tests/WgetFeature.cfg
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
%skip_messages = (
|
||||||
|
https => "Not running test: Wget under test doesn't support HTTPS.",
|
||||||
|
iri => "Not running test: Wget under test doesn't support IDN/IRI.",
|
||||||
|
);
|
||||||
|
|
||||||
|
1;
|
29
tests/WgetFeature.pm
Normal file
29
tests/WgetFeature.pm
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package WgetFeature;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use WgetTest;
|
||||||
|
|
||||||
|
our %skip_messages;
|
||||||
|
require 'WgetFeature.cfg';
|
||||||
|
|
||||||
|
sub import
|
||||||
|
{
|
||||||
|
my ($class, $feature) = @_;
|
||||||
|
|
||||||
|
my $output = `$WgetTest::WGETPATH --version`;
|
||||||
|
my ($list) = $output =~ /^([\+\-]\S+(?:\s+[\+\-]\S+)+)/m;
|
||||||
|
my %have_features = map {
|
||||||
|
my $feature = $_;
|
||||||
|
$feature =~ s/^.//;
|
||||||
|
($feature, /^\+/ ? 1 : 0);
|
||||||
|
} split /\s+/, $list;
|
||||||
|
|
||||||
|
unless ($have_features{$feature}) {
|
||||||
|
print $skip_messages{$feature}, "\n";
|
||||||
|
exit 2; # skip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
38
tests/run-px
38
tests/run-px
@ -4,8 +4,7 @@ use 5.006;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Term::ANSIColor ':constants';
|
use Term::ANSIColor;
|
||||||
$Term::ANSIColor::AUTORESET = 1;
|
|
||||||
|
|
||||||
die "Please specify the top source directory.\n" if (!@ARGV);
|
die "Please specify the top source directory.\n" if (!@ARGV);
|
||||||
my $top_srcdir = shift @ARGV;
|
my $top_srcdir = shift @ARGV;
|
||||||
@ -82,26 +81,42 @@ my @tested;
|
|||||||
foreach my $test (@tests) {
|
foreach my $test (@tests) {
|
||||||
print "Running $test\n\n";
|
print "Running $test\n\n";
|
||||||
system("$^X -I$top_srcdir/tests $top_srcdir/tests/$test $top_srcdir");
|
system("$^X -I$top_srcdir/tests $top_srcdir/tests/$test $top_srcdir");
|
||||||
push @tested, { name => $test, result => $? };
|
push @tested, { name => $test, result => $? >> 8 };
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
|
foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
|
||||||
delete $ENV{$var};
|
delete $ENV{$var};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my %exit = (
|
||||||
|
pass => 0,
|
||||||
|
fail => 1,
|
||||||
|
skip => 2,
|
||||||
|
unknown => 3, # or greater
|
||||||
|
);
|
||||||
|
|
||||||
|
my %colors = (
|
||||||
|
$exit{pass} => colored('pass:', 'green' ),
|
||||||
|
$exit{fail} => colored('FAIL:', 'red' ),
|
||||||
|
$exit{skip} => colored('Skip:', 'yellow' ),
|
||||||
|
$exit{unknown} => colored('Unknown:', 'magenta'),
|
||||||
|
);
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
foreach my $test (@tested) {
|
foreach my $test (@tested) {
|
||||||
($test->{result} == 0)
|
my $colored = exists $colors{$test->{result}}
|
||||||
? print GREEN 'pass: '
|
? $colors{$test->{result}}
|
||||||
: print RED 'FAIL: ';
|
: $colors{$exit{unknown}};
|
||||||
print $test->{name}, "\n";
|
print "$colored $test->{name}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $count = sub
|
my $count = sub
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
pass => sub { scalar grep $_->{result} == 0, @tested },
|
pass => sub { scalar grep $_->{result} == $exit{pass}, @tested },
|
||||||
fail => sub { scalar grep $_->{result} != 0, @tested },
|
fail => sub { scalar grep $_->{result} == $exit{fail}, @tested },
|
||||||
|
skip => sub { scalar grep $_->{result} == $exit{skip}, @tested },
|
||||||
|
unknown => sub { scalar grep $_->{result} >= $exit{unknown}, @tested },
|
||||||
}->{$_[0]}->();
|
}->{$_[0]}->();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -110,6 +125,7 @@ my $summary = sub
|
|||||||
my @lines = (
|
my @lines = (
|
||||||
"${\scalar @tested} tests were run",
|
"${\scalar @tested} tests were run",
|
||||||
"${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
|
"${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
|
||||||
|
"${\$count->('skip')} SKIP, ${\$count->('unknown')} UNKNOWN",
|
||||||
);
|
);
|
||||||
my $len_longest = sub
|
my $len_longest = sub
|
||||||
{
|
{
|
||||||
@ -129,8 +145,8 @@ my $summary = sub
|
|||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
print $count->('fail')
|
print $count->('fail')
|
||||||
? RED $summary
|
? colored($summary, 'red')
|
||||||
: GREEN $summary;
|
: colored($summary, 'green');
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
exit $count->('fail');
|
exit $count->('fail');
|
||||||
|
Loading…
Reference in New Issue
Block a user