Commit | Line | Data |
b965d173 |
1 | #!/usr/bin/perl -w |
2 | |
3 | BEGIN { |
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 | |
16 | use strict; |
b965d173 |
17 | use Test::More ( $^O eq 'VMS' ? ( skip_all => 'VMS' ) : ( tests => 3 ) ); |
18 | |
19 | use Config; |
20 | use TAP::Parser; |
21 | |
5e2a19fc |
22 | my $lib_path = join( ', ', map "'$_'", grep !ref, grep defined, @INC ); |
23 | |
b965d173 |
24 | sub 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 |
46 | BEGIN { unshift @INC, ( %s ); } |
b965d173 |
47 | use Test::More tests => 1; |
48 | |
5e2a19fc |
49 | ok grep(/^wibble$/, @INC) or diag join "\n", @INC; |
b965d173 |
50 | END |
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 |
61 | BEGIN { unshift @INC, ( %s ); } |
b965d173 |
62 | use Test::More tests => 1; |
63 | |
5e2a19fc |
64 | ok grep(/^wibble$/, @INC) or diag join "\n", @INC; |
b965d173 |
65 | END |
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 | |
74 | print "1..1\n"; |
75 | print $INC{'strict.pm'} ? "ok 1\n" : "not ok 1\n"; |
76 | END |
77 | } |
78 | |
79 | 1; |