Move the modules, tests, prove and Changes file from lib/ to
[p5sagit/p5-mst-13.2.git] / ext / Test / Harness / t / taint.t
CommitLineData
b965d173 1#!/usr/bin/perl -w
2
3BEGIN {
5e2a19fc 4 if ( $ENV{PERL_CORE} ) {
5 chdir 't';
6 @INC = ( '../lib', 'lib' );
7 }
8 else {
9 unshift @INC, 't/lib';
b965d173 10 }
11}
12
13# Test that options in PERL5LIB and PERL5OPT are propogated to tainted
14# tests
15
16use strict;
b965d173 17use Test::More ( $^O eq 'VMS' ? ( skip_all => 'VMS' ) : ( tests => 3 ) );
18
19use Config;
20use TAP::Parser;
21
5e2a19fc 22my $lib_path = join( ', ', map "'$_'", grep !ref, grep defined, @INC );
23
b965d173 24sub run_test_file {
25 my ( $test_template, @args ) = @_;
26
5e2a19fc 27 my $test_file = 'temp_test.tmp';
b965d173 28
29 open TEST, ">$test_file" or die $!;
30 printf TEST $test_template, @args;
31 close TEST;
32
33 my $p = TAP::Parser->new( { source => $test_file } );
34 1 while $p->next;
35 ok !$p->has_problems;
36
37 unlink $test_file;
38}
39
40{
41 local $ENV{PERL5LIB} = join $Config{path_sep}, grep defined, 'wibble',
42 $ENV{PERL5LIB};
5e2a19fc 43 run_test_file( <<'END', $lib_path );
b965d173 44#!/usr/bin/perl -T
45
5e2a19fc 46BEGIN { unshift @INC, ( %s ); }
b965d173 47use Test::More tests => 1;
48
5e2a19fc 49ok grep(/^wibble$/, @INC) or diag join "\n", @INC;
b965d173 50END
51}
52
53{
54 my $perl5lib = $ENV{PERL5LIB};
55 local $ENV{PERL5LIB};
56 local $ENV{PERLLIB} = join $Config{path_sep}, grep defined, 'wibble',
57 $perl5lib;
5e2a19fc 58 run_test_file( <<'END', $lib_path );
b965d173 59#!/usr/bin/perl -T
60
5e2a19fc 61BEGIN { unshift @INC, ( %s ); }
b965d173 62use Test::More tests => 1;
63
5e2a19fc 64ok grep(/^wibble$/, @INC) or diag join "\n", @INC;
b965d173 65END
66}
67
68{
5e2a19fc 69 local $ENV{PERL5LIB} = join $Config{path_sep}, @INC;
b965d173 70 local $ENV{PERL5OPT} = '-Mstrict';
71 run_test_file(<<'END');
72#!/usr/bin/perl -T
73
74print "1..1\n";
75print $INC{'strict.pm'} ? "ok 1\n" : "not ok 1\n";
76END
77}
78
791;