Move the modules, tests, prove and Changes file from lib/ to
[p5sagit/p5-mst-13.2.git] / ext / Test / Harness / t / compat / inc-propagation.t
CommitLineData
b965d173 1#!/usr/bin/perl -w
2
3# Test that @INC is propogated from the harness process to the test
4# process.
5
6use strict;
7use lib 't/lib';
8
9sub has_crazy_patch {
10 my $sentinel = 'blirpzoffle';
11 local $ENV{PERL5LIB} = $sentinel;
12 my $command = join ' ',
13 map {qq{"$_"}} ( $^X, '-e', 'print join q(:), @INC' );
14 my $path = `$command`;
15 my @got = ( $path =~ /($sentinel)/g );
16 return @got > 1;
17}
18
19use Test::More (
20 $^O eq 'VMS' ? ( skip_all => 'VMS' )
21 : has_crazy_patch() ? ( skip_all => 'Incompatible @INC patch' )
22 : ( tests => 2 )
23);
24
b965d173 25use Test::Harness;
26
27# Change @INC so we ensure it's preserved.
28use lib 'wibble';
29
b965d173 30my $test_template = <<'END';
31#!/usr/bin/perl %s
32
33use Test::More tests => 2;
34
b965d173 35# Make sure we did something sensible with PERL5LIB
36like $ENV{PERL5LIB}, qr{wibble};
f7c69158 37ok grep { $_ eq 'wibble' } @INC;
b965d173 38
b965d173 39END
40
41open TEST, ">inc_check.t.tmp";
f7c69158 42printf TEST $test_template, '';
b965d173 43close TEST;
44
45open TEST, ">inc_check_taint.t.tmp";
f7c69158 46printf TEST $test_template, '-T';
b965d173 47close TEST;
48END { 1 while unlink 'inc_check_taint.t.tmp', 'inc_check.t.tmp'; }
49
50for my $test ( 'inc_check_taint.t.tmp', 'inc_check.t.tmp' ) {
51 my ( $tot, $failed ) = Test::Harness::execute_tests( tests => [$test] );
52 is $tot->{bad}, 0;
53}
541;