1#!/usr/bin/perl -w 2 3# Test that PERL5LIB is propogated from the harness process to the test 4# process. 5 6use strict; 7use warnings; 8use lib 't/lib'; 9use Config; 10 11my $path_sep = $Config{path_sep}; 12 13sub has_crazy_patch { 14 my $sentinel = 'blirpzoffle'; 15 local $ENV{PERL5LIB} = $sentinel; 16 my $command = join ' ', 17 map {qq{"$_"}} ( $^X, '-e', 'print join q(:), @INC' ); 18 my $path = `$command`; 19 my @got = ( $path =~ /($sentinel)/g ); 20 return @got > 1; 21} 22 23use Test::More ( 24 $^O eq 'VMS' ? ( skip_all => 'VMS' ) 25 : has_crazy_patch() ? ( skip_all => 'Incompatible @INC patch' ) 26 : ( tests => 1 ) 27); 28 29use Test::Harness; 30use App::Prove; 31 32# Change PERL5LIB so we ensure it's preserved. 33$ENV{PERL5LIB} = join( 34 $path_sep, 'wibble', 35 $ENV{PERL5LIB} || '' 36); 37 38open TEST, ">perl5lib_check.t.tmp"; 39print TEST <<"END"; 40#!/usr/bin/perl 41use strict; 42use Test::More tests => 1; 43like \$ENV{PERL5LIB}, qr/(^|${path_sep})wibble${path_sep}/; 44END 45close TEST; 46 47END { 1 while unlink 'perl5lib_check.t.tmp'; } 48 49my $h = TAP::Harness->new( { lib => ['something'], verbosity => -3 } ); 50ok( !$h->runtests('perl5lib_check.t.tmp')->has_errors ); 51 521; 53