summaryrefslogtreecommitdiff
path: root/cpan/Test-Harness/t/perl5lib.t
blob: 3947aa6055fabd1d1302a7584c1aa9a284c1cd05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl -w

# Test that PERL5LIB is propogated from the harness process to the test
# process.

use strict;
use lib 't/lib';
use Config;

my $path_sep = $Config{path_sep};

sub has_crazy_patch {
    my $sentinel = 'blirpzoffle';
    local $ENV{PERL5LIB} = $sentinel;
    my $command = join ' ',
      map {qq{"$_"}} ( $^X, '-e', 'print join q(:), @INC' );
    my $path = `$command`;
    my @got = ( $path =~ /($sentinel)/g );
    return @got > 1;
}

use Test::More (
      $^O eq 'VMS' ? ( skip_all => 'VMS' )
    : has_crazy_patch() ? ( skip_all => 'Incompatible @INC patch' )
    : ( tests => 1 )
);

use Test::Harness;
use App::Prove;

# Change PERL5LIB so we ensure it's preserved.
$ENV{PERL5LIB} = join(
    $path_sep, 'wibble',
    $ENV{PERL5LIB} || ''
);

open TEST, ">perl5lib_check.t.tmp";
print TEST <<"END";
#!/usr/bin/perl
use strict;
use Test::More tests => 1;
like \$ENV{PERL5LIB}, qr/(^|${path_sep})wibble${path_sep}/;
END
close TEST;

END { 1 while unlink 'perl5lib_check.t.tmp'; }

my $h = TAP::Harness->new( { lib => ['something'], verbosity => -3 } );
ok( !$h->runtests('perl5lib_check.t.tmp')->has_errors );

1;