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