Move Test::Harness from ext/ to cpan/
[p5sagit/p5-mst-13.2.git] / cpan / Test-Harness / t / perl5lib.t
1 #!/usr/bin/perl -w
2
3 # Test that PERL5LIB is propogated from the harness process to the test
4 # process.
5
6 use strict;
7 use lib 't/lib';
8 use Config;
9
10 my $path_sep = $Config{path_sep};
11
12 sub has_crazy_patch {
13     my $sentinel = 'blirpzoffle';
14     local $ENV{PERL5LIB} = $sentinel;
15     my $command = join ' ',
16       map {qq{"$_"}} ( $^X, '-e', 'print join q(:), @INC' );
17     my $path = `$command`;
18     my @got = ( $path =~ /($sentinel)/g );
19     return @got > 1;
20 }
21
22 use Test::More (
23       $^O eq 'VMS' ? ( skip_all => 'VMS' )
24     : has_crazy_patch() ? ( skip_all => 'Incompatible @INC patch' )
25     : ( tests => 1 )
26 );
27
28 use Test::Harness;
29 use App::Prove;
30
31 # Change PERL5LIB so we ensure it's preserved.
32 $ENV{PERL5LIB} = join(
33     $path_sep, 'wibble',
34     ( $ENV{PERL_CORE} ? '../lib' : () ), $ENV{PERL5LIB} || ''
35 );
36
37 open TEST, ">perl5lib_check.t.tmp";
38 print TEST <<"END";
39 #!/usr/bin/perl
40 use strict;
41 use Test::More tests => 1;
42 like \$ENV{PERL5LIB}, qr/(^|${path_sep})wibble${path_sep}/;
43 END
44 close TEST;
45
46 END { 1 while unlink 'perl5lib_check.t.tmp'; }
47
48 my $h = TAP::Harness->new( { lib => ['something'], verbosity => -3 } );
49 ok( !$h->runtests('perl5lib_check.t.tmp')->has_errors );
50
51 1;