File: prove-switches.t

package info (click to toggle)
libtest-harness-perl 2.64-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 504 kB
  • ctags: 201
  • sloc: perl: 3,789; makefile: 45; sh: 10
file content (75 lines) | stat: -rw-r--r-- 2,435 bytes parent folder | download
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
BEGIN {
    if( $ENV{PERL_CORE} ) {
        chdir 't';
        @INC = ('../lib', 'lib');
    }
    else {
        unshift @INC, 't/lib';
    }
}

use strict;
use File::Spec;
use Test::More;
plan skip_all => "Not adapted to perl core" if $ENV{PERL_CORE};
plan skip_all => "Not installing prove" if -e "t/SKIP-PROVE";

# Work around a Cygwin bug.  Remove this if Perl bug 30952 ever gets fixed.
# http://rt.perl.org/rt3/Ticket/Display.html?id=30952.
plan skip_all => "Skipping because of a Cygwin bug" if ( $^O =~ /cygwin/i );

plan tests => 8;

my $blib = File::Spec->catfile( File::Spec->curdir, "blib" );
my $blib_lib = File::Spec->catfile( $blib, "lib" );
my $blib_arch = File::Spec->catfile( $blib, "arch" );
my $prove = File::Spec->catfile( $blib, "script", "prove" );
$prove = "$^X $prove";

CAPITAL_TAINT: {
    local $ENV{PROVE_SWITCHES};

    my @actual = qx/$prove -Ifirst -D -I second -Ithird -Tvdb/;
    my @expected = ( "# \$Test::Harness::Switches: -T -I$blib_arch -I$blib_lib -Ifirst -Isecond -Ithird\n" );
    is_deeply( \@actual, \@expected, "Capital taint flags OK" );
}

LOWERCASE_TAINT: {
    local $ENV{PROVE_SWITCHES};

    my @actual = qx/$prove -dD -Ifirst -I second -t -Ithird -vb/;
    my @expected = ( "# \$Test::Harness::Switches: -t -I$blib_arch -I$blib_lib -Ifirst -Isecond -Ithird\n" );
    is_deeply( \@actual, \@expected, "Lowercase taint OK" );
}

PROVE_SWITCHES: {
    local $ENV{PROVE_SWITCHES} = "-dvb -I fark";

    my @actual = qx/$prove -Ibork -Dd/;
    my @expected = ( "# \$Test::Harness::Switches: -I$blib_arch -I$blib_lib -Ifark -Ibork\n" );
    is_deeply( \@actual, \@expected, "PROVE_SWITCHES OK" );
}

PROVE_SWITCHES_L: {
    my @actual = qx/$prove -l -Ibongo -Dd/;
    my @expected = ( "# \$Test::Harness::Switches: -Ilib -Ibongo\n" );
    is_deeply( \@actual, \@expected, "PROVE_SWITCHES OK" );
}

PROVE_SWITCHES_LB: {
    my @actual = qx/$prove -lb -Dd/;
    my @expected = ( "# \$Test::Harness::Switches: -Ilib -I$blib_arch -I$blib_lib\n" );
    is_deeply( \@actual, \@expected, "PROVE_SWITCHES OK" );
}

PROVE_VERSION: {
    # This also checks that the prove $VERSION is in sync with Test::Harness's $VERSION
    local $/ = undef;

    use_ok( 'Test::Harness' );

    my $thv = $Test::Harness::VERSION;
    my @actual = qx/$prove --version/;
    is( scalar @actual, 1, 'Only 1 line returned' );
    like( $actual[0], qq{/^\Qprove v$thv, using Test::Harness v$thv and Perl v5\E/} );
}