1#!/usr/bin/perl -w 2 3BEGIN { 4 unshift @INC, 't/lib'; 5} 6 7# Test that environment options are propagated to tainted tests 8 9use strict; 10use warnings; 11use Test::More ( $^O eq 'VMS' ? ( skip_all => 'VMS' ) : ( tests => 2 ) ); 12 13use Config; 14use TAP::Parser; 15 16my $lib_path = join( ', ', map "'$_'", grep !ref, grep defined, @INC ); 17 18sub run_test_file { 19 my ( $test_template, @args ) = @_; 20 21 my $test_file = 'temp_test.tmp'; 22 23 open TEST, ">$test_file" or die $!; 24 printf TEST $test_template, @args; 25 close TEST; 26 27 my $p = TAP::Parser->new( 28 { source => $test_file, 29 30 # Test taint when there's spaces in a -I path 31 switches => [q["-Ifoo bar"]], 32 } 33 ); 34 1 while $p->next; 35 ok !$p->has_problems; 36 37 unlink $test_file; 38} 39 40{ 41 local $ENV{PERL5OPT} 42 = $ENV{PERL_CORE} ? '-I../../lib -Mstrict' : '-Mstrict'; 43 run_test_file(<<'END'); 44#!/usr/bin/perl -T 45 46print "1..1\n"; 47print $INC{'strict.pm'} ? "ok 1\n" : "not ok 1\n"; 48END 49} 50 51 52# Check that PERL5LIB is propagated to -T. 53{ 54 my $sentinel_dir = 'i/do/not/exist'; 55 local $ENV{PERL5LIB} = join $Config{path_sep}, $ENV{PERL5LIB} || '', $sentinel_dir; 56 run_test_file(sprintf <<'END', $sentinel_dir); 57#!/usr/bin/perl -T 58 59print "1..1\n"; 60my $ok = grep { $_ eq '%s' } @INC; 61print $ok ? "ok 1\n" : "not ok 1\n"; 62END 63} 64 651; 66