Upgrade to ExtUtils-Manifest-1.49.
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / Install.t
CommitLineData
479d2113 1#!/usr/bin/perl -w
2
3# Test ExtUtils::Install.
4
5BEGIN {
6 if( $ENV{PERL_CORE} ) {
50192506 7 @INC = ('../../lib', '../lib', 'lib');
479d2113 8 }
9 else {
10 unshift @INC, 't/lib';
11 }
12}
13chdir 't';
14
15use strict;
16use TieOut;
17use File::Path;
18use File::Spec;
19
3a465856 20use Test::More tests => 33;
a7d1454b 21
22use MakeMaker::Test::Setup::BFD;
479d2113 23
24BEGIN { use_ok('ExtUtils::Install') }
25
26# Check exports.
27foreach my $func (qw(install uninstall pm_to_blib install_default)) {
28 can_ok(__PACKAGE__, $func);
29}
30
31
a7d1454b 32ok( setup_recurs(), 'setup' );
33END {
34 ok( chdir File::Spec->updir );
35 ok( teardown_recurs(), 'teardown' );
36}
37
479d2113 38chdir 'Big-Dummy';
39
40my $stdout = tie *STDOUT, 'TieOut';
41pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' },
42 'blib/lib/auto'
43 );
1df8d179 44END { rmtree 'blib' }
45
479d2113 46ok( -d 'blib/lib', 'pm_to_blib created blib dir' );
47ok( -r 'blib/lib/Big/Dummy.pm', ' copied .pm file' );
48ok( -r 'blib/lib/auto', ' created autosplit dir' );
49is( $stdout->read, "cp lib/Big/Dummy.pm blib/lib/Big/Dummy.pm\n" );
50
51pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' },
52 'blib/lib/auto'
53 );
54ok( -d 'blib/lib', 'second run, blib dir still there' );
55ok( -r 'blib/lib/Big/Dummy.pm', ' .pm file still there' );
56ok( -r 'blib/lib/auto', ' autosplit still there' );
57is( $stdout->read, "Skip blib/lib/Big/Dummy.pm (unchanged)\n" );
58
ab00ffcd 59install( { 'blib/lib' => 'install-test/lib/perl',
60 read => 'install-test/packlist',
61 write => 'install-test/packlist'
62 },
63 0, 1);
2530b651 64ok( ! -d 'install-test/lib/perl', 'install made dir (dry run)');
65ok( ! -r 'install-test/lib/perl/Big/Dummy.pm',
66 ' .pm file installed (dry run)');
67ok( ! -r 'install-test/packlist', ' packlist exists (dry run)');
479d2113 68
69install( { 'blib/lib' => 'install-test/lib/perl',
70 read => 'install-test/packlist',
71 write => 'install-test/packlist'
72 } );
73ok( -d 'install-test/lib/perl', 'install made dir' );
74ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' .pm file installed' );
3a465856 75ok(!-r 'install-test/lib/perl/Big/Dummy.SKIP', ' ignored .SKIP file' );
479d2113 76ok( -r 'install-test/packlist', ' packlist exists' );
77
78open(PACKLIST, 'install-test/packlist' );
79my %packlist = map { chomp; ($_ => 1) } <PACKLIST>;
80close PACKLIST;
81
3a465856 82# On case-insensitive filesystems (ie. VMS), the keys of the packlist might
479d2113 83# be lowercase. :(
84my $native_dummy = File::Spec->catfile(qw(install-test lib perl Big Dummy.pm));
85is( keys %packlist, 1 );
86is( lc((keys %packlist)[0]), lc $native_dummy, 'packlist written' );
87
1df8d179 88
89# Test UNINST=1 preserving same versions in other dirs.
90install( { 'blib/lib' => 'install-test/other_lib/perl',
91 read => 'install-test/packlist',
92 write => 'install-test/packlist'
93 },
94 0, 0, 1);
95ok( -d 'install-test/other_lib/perl', 'install made other dir' );
96ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
97ok( -r 'install-test/packlist', ' packlist exists' );
98ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' UNINST=1 preserved same' );
99
100
101
102# Test UNINST=1 removing other versions in other dirs.
103chmod 0644, 'blib/lib/Big/Dummy.pm' or die $!;
104open(DUMMY, ">>blib/lib/Big/Dummy.pm") or die $!;
105print DUMMY "Extra stuff\n";
106close DUMMY;
107
108{
109 local @INC = ('install-test/lib/perl');
110 local $ENV{PERL5LIB} = '';
111 install( { 'blib/lib' => 'install-test/other_lib/perl',
112 read => 'install-test/packlist',
113 write => 'install-test/packlist'
114 },
115 0, 0, 1);
116 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
117 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
118 ok( -r 'install-test/packlist', ' packlist exists' );
119 ok( !-r 'install-test/lib/perl/Big/Dummy.pm',
120 ' UNINST=1 removed different' );
121}