| 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 warnings; |
| 8 |
use lib 't/lib'; |
| 9 |
use Config; |
| 10 |
|
| 11 |
local |
| 12 |
$ENV{PERL5OPT}; # avoid any user-provided PERL5OPT from contaminating @INC |
| 13 |
|
| 14 |
sub has_crazy_patch { |
| 15 |
my $sentinel = 'blirpzoffle'; |
| 16 |
local $ENV{PERL5LIB} = $sentinel; |
| 17 |
my $command = join ' ', |
| 18 |
map {qq{"$_"}} ( $^X, '-e', 'print join q(:), @INC' ); |
| 19 |
my $path = `$command`; |
| 20 |
my @got = ( $path =~ /($sentinel)/g ); |
| 21 |
return @got > 1; |
| 22 |
} |
| 23 |
|
| 24 |
use Test::More ( |
| 25 |
$^O eq 'VMS' ? ( skip_all => 'VMS' ) |
| 26 |
: has_crazy_patch() ? ( skip_all => 'Incompatible @INC patch' ) |
| 27 |
: exists $ENV{HARNESS_PERL_SWITCHES} |
| 28 |
? ( skip_all => 'Someone messed with HARNESS_PERL_SWITCHES' ) |
| 29 |
: ( tests => 2 ) |
| 30 |
); |
| 31 |
|
| 32 |
use Test::Harness; |
| 33 |
|
| 34 |
# Change @INC so we ensure it's preserved. |
| 35 |
use lib 'wibble'; |
| 36 |
|
| 37 |
my $test_template = <<'END'; |
| 38 |
#!/usr/bin/perl %s |
| 39 |
|
| 40 |
use Test::More tests => 1; |
| 41 |
|
| 42 |
is $INC[0], "wibble", 'basic order of @INC preserved' or diag "\@INC: @INC"; |
| 43 |
|
| 44 |
END |
| 45 |
|
| 46 |
open TEST, ">inc_check.t.tmp"; |
| 47 |
printf TEST $test_template, ''; |
| 48 |
close TEST; |
| 49 |
|
| 50 |
open TEST, ">inc_check_taint.t.tmp"; |
| 51 |
printf TEST $test_template, '-T'; |
| 52 |
close TEST; |
| 53 |
END { 1 while unlink 'inc_check_taint.t.tmp', 'inc_check.t.tmp'; } |
| 54 |
|
| 55 |
for my $test ( 'inc_check_taint.t.tmp', 'inc_check.t.tmp' ) { |
| 56 |
my ( $tot, $failed ) = Test::Harness::execute_tests( tests => [$test] ); |
| 57 |
is $tot->{bad}, 0; |
| 58 |
} |
| 59 |
1; |