Commit | Line | Data |
b965d173 |
1 | #!/usr/bin/perl -w |
2 | |
3 | # Test that @INC is propogated from the harness process to the test |
4 | # process. |
5 | |
6 | use strict; |
7 | use lib 't/lib'; |
8 | |
9 | sub has_crazy_patch { |
10 | my $sentinel = 'blirpzoffle'; |
11 | local $ENV{PERL5LIB} = $sentinel; |
12 | my $command = join ' ', |
13 | map {qq{"$_"}} ( $^X, '-e', 'print join q(:), @INC' ); |
14 | my $path = `$command`; |
15 | my @got = ( $path =~ /($sentinel)/g ); |
16 | return @got > 1; |
17 | } |
18 | |
19 | use Test::More ( |
20 | $^O eq 'VMS' ? ( skip_all => 'VMS' ) |
21 | : has_crazy_patch() ? ( skip_all => 'Incompatible @INC patch' ) |
22 | : ( tests => 2 ) |
23 | ); |
24 | |
b965d173 |
25 | use Test::Harness; |
26 | |
27 | # Change @INC so we ensure it's preserved. |
28 | use lib 'wibble'; |
29 | |
b965d173 |
30 | my $test_template = <<'END'; |
31 | #!/usr/bin/perl %s |
32 | |
33 | use Test::More tests => 2; |
34 | |
b965d173 |
35 | # Make sure we did something sensible with PERL5LIB |
36 | like $ENV{PERL5LIB}, qr{wibble}; |
f7c69158 |
37 | ok grep { $_ eq 'wibble' } @INC; |
b965d173 |
38 | |
b965d173 |
39 | END |
40 | |
41 | open TEST, ">inc_check.t.tmp"; |
f7c69158 |
42 | printf TEST $test_template, ''; |
b965d173 |
43 | close TEST; |
44 | |
45 | open TEST, ">inc_check_taint.t.tmp"; |
f7c69158 |
46 | printf TEST $test_template, '-T'; |
b965d173 |
47 | close TEST; |
48 | END { 1 while unlink 'inc_check_taint.t.tmp', 'inc_check.t.tmp'; } |
49 | |
50 | for my $test ( 'inc_check_taint.t.tmp', 'inc_check.t.tmp' ) { |
51 | my ( $tot, $failed ) = Test::Harness::execute_tests( tests => [$test] ); |
52 | is $tot->{bad}, 0; |
53 | } |
54 | 1; |