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