OS2 patches
[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
1df8d179 20use Test::More tests => 29;
479d2113 21
22BEGIN { use_ok('ExtUtils::Install') }
23
24# Check exports.
25foreach my $func (qw(install uninstall pm_to_blib install_default)) {
26 can_ok(__PACKAGE__, $func);
27}
28
29
30chdir 'Big-Dummy';
31
32my $stdout = tie *STDOUT, 'TieOut';
33pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' },
34 'blib/lib/auto'
35 );
1df8d179 36END { rmtree 'blib' }
37
479d2113 38ok( -d 'blib/lib', 'pm_to_blib created blib dir' );
39ok( -r 'blib/lib/Big/Dummy.pm', ' copied .pm file' );
40ok( -r 'blib/lib/auto', ' created autosplit dir' );
41is( $stdout->read, "cp lib/Big/Dummy.pm blib/lib/Big/Dummy.pm\n" );
42
43pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' },
44 'blib/lib/auto'
45 );
46ok( -d 'blib/lib', 'second run, blib dir still there' );
47ok( -r 'blib/lib/Big/Dummy.pm', ' .pm file still there' );
48ok( -r 'blib/lib/auto', ' autosplit still there' );
49is( $stdout->read, "Skip blib/lib/Big/Dummy.pm (unchanged)\n" );
50
ab00ffcd 51install( { 'blib/lib' => 'install-test/lib/perl',
52 read => 'install-test/packlist',
53 write => 'install-test/packlist'
54 },
55 0, 1);
2530b651 56ok( ! -d 'install-test/lib/perl', 'install made dir (dry run)');
57ok( ! -r 'install-test/lib/perl/Big/Dummy.pm',
58 ' .pm file installed (dry run)');
59ok( ! -r 'install-test/packlist', ' packlist exists (dry run)');
479d2113 60
61install( { 'blib/lib' => 'install-test/lib/perl',
62 read => 'install-test/packlist',
63 write => 'install-test/packlist'
64 } );
65ok( -d 'install-test/lib/perl', 'install made dir' );
66ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' .pm file installed' );
67ok( -r 'install-test/packlist', ' packlist exists' );
68
69open(PACKLIST, 'install-test/packlist' );
70my %packlist = map { chomp; ($_ => 1) } <PACKLIST>;
71close PACKLIST;
72
73# On case-insensitive filesystems (ie. VMS), the keys of the packlist might
74# be lowercase. :(
75my $native_dummy = File::Spec->catfile(qw(install-test lib perl Big Dummy.pm));
76is( keys %packlist, 1 );
77is( lc((keys %packlist)[0]), lc $native_dummy, 'packlist written' );
78
1df8d179 79
80# Test UNINST=1 preserving same versions in other dirs.
81install( { 'blib/lib' => 'install-test/other_lib/perl',
82 read => 'install-test/packlist',
83 write => 'install-test/packlist'
84 },
85 0, 0, 1);
86ok( -d 'install-test/other_lib/perl', 'install made other dir' );
87ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
88ok( -r 'install-test/packlist', ' packlist exists' );
89ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' UNINST=1 preserved same' );
90
91
92
93# Test UNINST=1 removing other versions in other dirs.
94chmod 0644, 'blib/lib/Big/Dummy.pm' or die $!;
95open(DUMMY, ">>blib/lib/Big/Dummy.pm") or die $!;
96print DUMMY "Extra stuff\n";
97close DUMMY;
98
99{
100 local @INC = ('install-test/lib/perl');
101 local $ENV{PERL5LIB} = '';
102 install( { 'blib/lib' => 'install-test/other_lib/perl',
103 read => 'install-test/packlist',
104 write => 'install-test/packlist'
105 },
106 0, 0, 1);
107 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
108 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
109 ok( -r 'install-test/packlist', ' packlist exists' );
110 ok( !-r 'install-test/lib/perl/Big/Dummy.pm',
111 ' UNINST=1 removed different' );
112}