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