diff options
Diffstat (limited to 'tests/WgetFeature.pm')
-rw-r--r-- | tests/WgetFeature.pm | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/tests/WgetFeature.pm b/tests/WgetFeature.pm index f58b998..28e0c11 100644 --- a/tests/WgetFeature.pm +++ b/tests/WgetFeature.pm @@ -3,26 +3,41 @@ package WgetFeature; use strict; use warnings; -use WgetTest; +our $VERSION = 0.01; -our %skip_messages; -require 'WgetFeature.cfg'; +use Carp; +use English qw(-no_match_vars); +use FindBin; +use WgetTests; + +our %SKIP_MESSAGES; +{ + my $cfgfile = "$FindBin::Bin/WgetFeature.cfg"; + open my $fh, '<', $cfgfile + or croak "Cannot open '$cfgfile': $ERRNO"; + my @lines = <$fh>; + close $fh or carp "Cannot close '$cfgfile': $ERRNO"; + my $evalstr = join q{}, @lines; + eval { $evalstr } or carp "Cannot eval '$cfgfile': $ERRNO"; +} 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 + my ($list) = $output =~ m/^([+-]\S+(?:\s+[+-]\S+)+)/msx; + my %have_features; + for my $f (split m/\s+/msx, $list) + { + my $feat = $f; + $feat =~ s/^.//msx; + $have_features{$feat} = $f =~ m/^[+]/msx ? 1 : 0; + } + if (!$have_features{$feature}) + { + print "$SKIP_MESSAGES{$feature}\n"; + exit 77; # skip } } |