]> sjero.net Git - wget/commitdiff
Enhance tests to include feature checking.
authorSteven Schubiger <stsc@member.fsf.org>
Sat, 5 Sep 2009 20:54:05 +0000 (22:54 +0200)
committerSteven Schubiger <stsc@member.fsf.org>
Sat, 5 Sep 2009 20:54:05 +0000 (22:54 +0200)
18 files changed:
tests/ChangeLog
tests/Makefile.am
tests/Test-ftp-iri-disabled.px
tests/Test-ftp-iri-fallback.px
tests/Test-ftp-iri-recursive.px
tests/Test-ftp-iri.px
tests/Test-idn-cmd.px
tests/Test-idn-headers.px
tests/Test-idn-meta.px
tests/Test-idn-robots.px
tests/Test-iri-forced-remote.px
tests/Test-iri-list.px
tests/Test-iri-percent.px
tests/Test-iri.px
tests/Test-proxied-https-auth.px
tests/WgetFeature.cfg [new file with mode: 0644]
tests/WgetFeature.pm [new file with mode: 0644]
tests/run-px

index 702c9d73e51ebc6c981c0b966563fe9282cd6c0b..f6327b2e3939cf524046a9bc3c14f76d72e79cfb 100644 (file)
@@ -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>
 
        * Makefile.am (unit-tests): explicit dependency is
 2009-09-02  Micah Cowan  <micah@cowan.name>
 
        * Makefile.am (unit-tests): explicit dependency is
index e4d0e96ba498225c944642eb078762ba5c93c6b7..ec68d6d5af685bcb8ea08937cf2e164129c3ae11 100644 (file)
@@ -60,6 +60,7 @@ run-px-tests: WgetTest.pm ../src/wget$(EXEEXT)
        $(srcdir)/run-px $(top_srcdir)
 
 EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
        $(srcdir)/run-px $(top_srcdir)
 
 EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
+             WgetFeature.pm WgetFeature.cfg \
              Test-auth-basic.px \
              Test-auth-no-challenge.px \
              Test-auth-no-challenge-url.px \
              Test-auth-basic.px \
              Test-auth-no-challenge.px \
              Test-auth-no-challenge-url.px \
index 17bb85c888bed27b13027c262b3f6acc3a17edef..4ded28ffd182316d1f365d9c350451707a393b5a 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(iri);
 use FTPTest;
 
 
 use FTPTest;
 
 
index f485721324d16067c77823a8e50e4a6ca7a990a8..c3f97385bab1e29d4a6a36261662b862934c08fd 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(iri);
 use FTPTest;
 
 
 use FTPTest;
 
 
index 5bbc8808067599e71102ba8139839771a5ac6137..1a664e950b8ca775bbef2e807238833b27f7ae6b 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(iri);
 use FTPTest;
 
 
 use FTPTest;
 
 
index 7bedb891c3ec29240d1bc2db1425a5aea6e48983..7594a80ca8448c1ef7810867bf1e2d4ec9366582 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(iri);
 use FTPTest;
 
 
 use FTPTest;
 
 
index 822803ae6325a8f11de330663a621bfaef7179e9..4f92ea0ca6b1dfb2cbeb1e4dfa0698428a83a2a1 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(iri);
 use HTTPTest;
 
 # " Kon'nichiwa <dot> Japan
 use HTTPTest;
 
 # " Kon'nichiwa <dot> Japan
index b94c1cde1d780ba8681f6a938132b43afd705f98..f58581373df13dad5ed96ec7eba2613bfeee63a6 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(iri);
 use HTTPTest;
 
 # " Kon'nichiwa <dot> Japan
 use HTTPTest;
 
 # " Kon'nichiwa <dot> Japan
index 2734e1eaf537ffc1d586c944979e5a4a61f556cc..199eabe2b48394c3d6e58c6ceeb49e012ea82f78 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(iri);
 use HTTPTest;
 
 # " Kon'nichiwa <dot> Japan
 use HTTPTest;
 
 # " Kon'nichiwa <dot> Japan
index ff5033f06b3e8baa1982a239486d14468a796b34..3f0f8ddea94e9daafdf362801a85c65b8295e59b 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(iri);
 use HTTPTest;
 
 # " Kon'nichiwa <dot> Japan
 use HTTPTest;
 
 # " Kon'nichiwa <dot> Japan
index 8341d516931d6d9a9071f08e91b89abb87133640..9c3d5b6be898fbafc49de62b28faad4d63c20662 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(iri);
 use HTTPTest;
 
 # cf. http://en.wikipedia.org/wiki/Latin1
 use HTTPTest;
 
 # cf. http://en.wikipedia.org/wiki/Latin1
index 87cc33c8e11c96a30d5702ef38f79ddacc80e13a..8110358a7c0404473cc4f666fcceb8d2fc0c9eaa 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(iri);
 use HTTPTest;
 
 # cf. http://en.wikipedia.org/wiki/Latin1
 use HTTPTest;
 
 # cf. http://en.wikipedia.org/wiki/Latin1
index 158392df0fa08af6dd932e609ca8c8d33cbf1eb0..2184b4d847987302795c02d98a942267741470f7 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(iri);
 use HTTPTest;
 
 # Just a sanity check to verify that %-encoded values are always left
 use HTTPTest;
 
 # Just a sanity check to verify that %-encoded values are always left
index 01e1c50a8b74a8bfd7301f14624cc979911873cb..f81ef38f8734cdb4ef4c92373e399adc69a3e0c1 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(iri);
 use HTTPTest;
 
 # cf. http://en.wikipedia.org/wiki/Latin1
 use HTTPTest;
 
 # cf. http://en.wikipedia.org/wiki/Latin1
index 2b37f32b2feff30bac3be449244e765635bdcc11..71d43b16d3ba6cee2619951a2ffb0680aad52bf6 100755 (executable)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use WgetFeature qw(https);
 use WgetTest;  # For $WGETPATH.
 
 my $cert_path;
 use WgetTest;  # For $WGETPATH.
 
 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::Request;
 use IO::Socket::SSL;
 use HTTP::Daemon;
 use HTTP::Request;
 use IO::Socket::SSL;
diff --git a/tests/WgetFeature.cfg b/tests/WgetFeature.cfg
new file mode 100644 (file)
index 0000000..a1176e0
--- /dev/null
@@ -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;
diff --git a/tests/WgetFeature.pm b/tests/WgetFeature.pm
new file mode 100644 (file)
index 0000000..f58b998
--- /dev/null
@@ -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;
index 5dade1bd7e72a3c00c2771cc81037956bfe4378c..29765c9516be14d9a027fa687f8cd362806b861d 100755 (executable)
@@ -4,8 +4,7 @@ use 5.006;
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
-use Term::ANSIColor ':constants';
-$Term::ANSIColor::AUTORESET = 1;
+use Term::ANSIColor;
 
 die "Please specify the top source directory.\n" if (!@ARGV);
 my $top_srcdir = shift @ARGV;
 
 die "Please specify the top source directory.\n" if (!@ARGV);
 my $top_srcdir = shift @ARGV;
@@ -82,26 +81,42 @@ my @tested;
 foreach my $test (@tests) {
     print "Running $test\n\n";
     system("$^X -I$top_srcdir/tests $top_srcdir/tests/$test $top_srcdir");
 foreach my $test (@tests) {
     print "Running $test\n\n";
     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)) {
     delete $ENV{$var};
 }
 
 }
 
 foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
     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";
 foreach my $test (@tested) {
 print "\n";
 foreach my $test (@tested) {
-    ($test->{result} == 0)
-      ? print GREEN 'pass: '
-      : print RED 'FAIL: ';
-   print $test->{name}, "\n";
+    my $colored = exists $colors{$test->{result}}
+      ? $colors{$test->{result}}
+      : $colors{$exit{unknown}};
+    print "$colored $test->{name}\n";
 }
 
 my $count = sub
 {
     return {
 }
 
 my $count = sub
 {
     return {
-      pass => sub { scalar grep $_->{result} == 0, @tested },
-      fail => sub { scalar grep $_->{result} != 0, @tested },
+      pass    => sub { scalar grep $_->{result} == $exit{pass},    @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 = (
         "${\scalar @tested} tests were run",
         "${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
     my @lines = (
         "${\scalar @tested} tests were run",
         "${\$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 $count->('fail')
 
 print "\n";
 print $count->('fail')
-  ? RED $summary
-  : GREEN $summary;
+  ? colored($summary, 'red')
+  : colored($summary, 'green');
 print "\n";
 
 exit $count->('fail');
 print "\n";
 
 exit $count->('fail');