summaryrefslogtreecommitdiff
path: root/tests/WgetFeature.pm
blob: 28e0c114b610e98e2fa605a73b6f6ae2f39f802b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package WgetFeature;

use strict;
use warnings;

our $VERSION = 0.01;

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 =~ 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
    }
}

1;