51ef4f1e54aca05da0e320f9eac3e5dc34fb309c
[p5sagit/local-lib.git] / t / de-dup.t
1 use strict;
2 use warnings;
3 use Test::More;
4 use File::Temp qw(tempdir);
5 use Cwd;
6
7 plan tests => 4;
8
9 my $dir = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1);
10
11 use local::lib ();
12 local::lib->import($dir);
13 local::lib->import($dir);
14
15 {
16     my (%inc, %perl5lib);
17     map { $inc{$_}++ } @INC;
18     map { $perl5lib{$_} } split /:/, $ENV{PERL5LIB};
19     ok ! grep({ $inc{$_} > 1 } keys %inc), '@INC entries not duplicated';
20     ok ! grep({ $perl5lib{$_} > 1 } keys %perl5lib), 'ENV{PERL5LIB} entries not duplicated';
21 }
22
23 local::lib->import('--self-contained', $dir);
24
25 {
26     my (%inc, %perl5lib);
27     map { $inc{$_}++ } @INC;
28     map { $perl5lib{$_} } split /:/, $ENV{PERL5LIB};
29     ok ! grep({ $inc{$_} > 1 } keys %inc), '@INC entries not duplicated (--self-contained)';
30     ok ! grep({ $perl5lib{$_} > 1 } keys %perl5lib), 'ENV{PERL5LIB} entries not duplicated (--self-contained)';
31 }
32