Move Test::Harness from ext/ to cpan/
[p5sagit/p5-mst-13.2.git] / cpan / Test-Harness / t / taint.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4     unshift @INC, 't/lib';
5 }
6
7 # Test that options in PERL5OPT are propogated to tainted tests
8
9 use strict;
10 use Test::More ( $^O eq 'VMS' ? ( skip_all => 'VMS' ) : ( tests => 1 ) );
11
12 use Config;
13 use TAP::Parser;
14
15 my $lib_path = join( ', ', map "'$_'", grep !ref, grep defined, @INC );
16
17 sub 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
44 print "1..1\n";
45 print $INC{'strict.pm'} ? "ok 1\n" : "not ok 1\n";
46 END
47 }
48
49 1;