source: trunk/essentials/dev-lang/perl/lib/ExtUtils/t/Install.t@ 3184

Last change on this file since 3184 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 3.8 KB
Line 
1#!/usr/bin/perl -w
2
3# Test ExtUtils::Install.
4
5BEGIN {
6 if( $ENV{PERL_CORE} ) {
7 @INC = ('../../lib', '../lib', 'lib');
8 }
9 else {
10 unshift @INC, 't/lib';
11 }
12}
13chdir 't';
14
15use strict;
16use TieOut;
17use File::Path;
18use File::Spec;
19
20use Test::More tests => 32;
21
22use MakeMaker::Test::Setup::BFD;
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
32ok( setup_recurs(), 'setup' );
33END {
34 ok( chdir File::Spec->updir );
35 ok( teardown_recurs(), 'teardown' );
36}
37
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 );
44END { rmtree 'blib' }
45
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
59install( { 'blib/lib' => 'install-test/lib/perl',
60 read => 'install-test/packlist',
61 write => 'install-test/packlist'
62 },
63 0, 1);
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)');
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' );
75ok( -r 'install-test/packlist', ' packlist exists' );
76
77open(PACKLIST, 'install-test/packlist' );
78my %packlist = map { chomp; ($_ => 1) } <PACKLIST>;
79close PACKLIST;
80
81# On case-insensitive filesystems (ie. VMS), the keys of the packlist might
82# be lowercase. :(
83my $native_dummy = File::Spec->catfile(qw(install-test lib perl Big Dummy.pm));
84is( keys %packlist, 1 );
85is( lc((keys %packlist)[0]), lc $native_dummy, 'packlist written' );
86
87
88# Test UNINST=1 preserving same versions in other dirs.
89install( { 'blib/lib' => 'install-test/other_lib/perl',
90 read => 'install-test/packlist',
91 write => 'install-test/packlist'
92 },
93 0, 0, 1);
94ok( -d 'install-test/other_lib/perl', 'install made other dir' );
95ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
96ok( -r 'install-test/packlist', ' packlist exists' );
97ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' UNINST=1 preserved same' );
98
99
100
101# Test UNINST=1 removing other versions in other dirs.
102chmod 0644, 'blib/lib/Big/Dummy.pm' or die $!;
103open(DUMMY, ">>blib/lib/Big/Dummy.pm") or die $!;
104print DUMMY "Extra stuff\n";
105close DUMMY;
106
107{
108 local @INC = ('install-test/lib/perl');
109 local $ENV{PERL5LIB} = '';
110 install( { 'blib/lib' => 'install-test/other_lib/perl',
111 read => 'install-test/packlist',
112 write => 'install-test/packlist'
113 },
114 0, 0, 1);
115 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
116 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
117 ok( -r 'install-test/packlist', ' packlist exists' );
118 ok( !-r 'install-test/lib/perl/Big/Dummy.pm',
119 ' UNINST=1 removed different' );
120}
Note: See TracBrowser for help on using the repository browser.