3 # *NOTE* This is executed by basic.t and is included in both ExtUtils-Install
4 # and ExtUtils-MakeMaker as well as Perl itself. Which bits of it execute depend
5 # on each given packages basic.t
7 # If you patch any version of this file please make sure you let the other
8 # distributions know as well. It should be identical in all three cases.
10 # This test puts MakeMaker through the paces of a basic perl module
11 # build, test and installation of the Big::Fat::Dummy module.
15 use ExtUtils::MakeMaker;
17 use Test::More tests => $::TESTS;
18 use MakeMaker::Test::Utils;
19 use MakeMaker::Test::Setup::BFD;
24 # 'make disttest' sets a bunch of environment variables which interfere
26 delete @ENV{qw(PREFIX LIB MAKEFLAGS)};
28 my $perl = which_perl();
29 my $Is_VMS = $^O eq 'VMS';
31 # GNV logical interferes with testing
32 $ENV{'bin'} = '[.bin]' if $Is_VMS;
38 my $Touch_Time = calibrate_mtime();
42 ok( setup_recurs(), 'setup' );
44 ok( chdir File::Spec->updir );
45 ok( teardown_recurs(), 'teardown' );
48 ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
49 diag("chdir failed: $!");
51 my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
52 END { rmtree '../dummy-install'; }
54 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
57 my $makefile = makefile_name();
58 ok( grep(/^Writing $makefile for Big::Dummy/,
60 'Makefile.PL output looks right');
62 ok( grep(/^Current package is: main$/,
64 'Makefile.PL run in package main');
66 ok( -e $makefile, 'Makefile exists' );
69 my $mtime = (stat($makefile))[9];
70 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
72 END { unlink makefile_name(), makefile_backup() }
74 my $make = make_run();
77 # Supress 'make manifest' noise
78 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
79 my $manifest_out = run("$make manifest");
80 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
81 ok( -s 'MANIFEST', ' its not empty' );
84 END { unlink 'MANIFEST'; }
86 unless ($::TEST_INSTALL_ONLY) {
87 my $ppd_out = run("$make ppd");
88 is( $?, 0, ' exited normally' ) || diag $ppd_out;
89 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
91 { local $/; $ppd_html = <PPD> }
93 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
95 like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' );
96 like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m, # Unconfuse highlighters: '
99 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
101 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
102 like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
104 like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
106 my $archname = $Config{archname};
107 $archname .= "-". substr($Config{version},0,3) if $] >= 5.008;
108 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$archname" />}m,
110 like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
111 like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
112 like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
113 END { unlink 'Big-Dummy.ppd' }
116 my $test_out = run("$make test");
117 like( $test_out, qr/All tests successful/, 'make test' );
118 is( $?, 0, ' exited normally' ) ||
121 # Test 'make test TEST_VERBOSE=1'
122 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
123 $test_out = run("$make_test_verbose");
124 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
125 like( $test_out, qr/All tests successful/, ' successful' );
126 is( $?, 0, ' exited normally' ) ||
129 # Test 'make install VERBINST=1'
130 my $make_install_verbinst = make_macro($make, 'install', VERBINST => 1);
131 my $install_out = run($make_install_verbinst);
132 is( $?, 0, 'install' ) || diag $install_out;
133 like( $install_out, qr/^Installing /m );
134 like( $install_out, qr/^Writing /m );
136 ok( -r '../dummy-install', ' install dir created' );
139 # do it case-insensitive for non-case preserving OSs
142 # VMS likes to put dots on the end of things that don't have them.
143 $file =~ s/\.$// if $Is_VMS;
145 $files{$file} = $File::Find::name;
146 }, '../dummy-install' );
147 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
148 ok( $files{'liar.pm'}, ' Liar.pm installed' );
149 ok( $files{'program'}, ' program installed' );
150 ok( $files{'.packlist'}, ' packlist created' );
151 ok( $files{'perllocal.pod'},' perllocal.pod created' );
155 skip 'VMS install targets do not preserve $(PREFIX)', 9 if $Is_VMS;
157 $install_out = run("$make install PREFIX=elsewhere VERBINST=1");
158 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
159 like( $install_out, qr/^Installing /m );
160 like( $install_out, qr/^Writing /m );
162 ok( -r 'elsewhere', ' install dir created' );
164 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
165 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
166 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
167 ok( $files{'program'}, ' program installed' );
168 ok( $files{'.packlist'}, ' packlist created' );
169 ok( $files{'perllocal.pod'},' perllocal.pod created' );
175 skip 'VMS install targets do not preserve $(DESTDIR)', 11 if $Is_VMS;
177 $install_out = run("$make install PREFIX= DESTDIR=other VERBINST=1");
178 is( $?, 0, 'install with DESTDIR' ) ||
180 like( $install_out, qr/^Installing /m );
181 like( $install_out, qr/^Writing /m );
183 ok( -d 'other', ' destdir created' );
187 $files{$_} = $File::Find::name;
189 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
190 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
191 ok( $files{'program'}, ' program installed' );
192 ok( $files{'.packlist'}, ' packlist created' );
193 ok( $files{'perllocal.pod'},' perllocal.pod created' );
195 ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
196 diag("Can't open $files{'perllocal.pod'}: $!");
198 unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
202 # TODO not available in the min version of Test::Harness we require
203 # ok( open(PACKLIST, $files{'.packlist'} ) ) ||
204 # diag("Can't open $files{'.packlist'}: $!");
206 # local $TODO = 'DESTDIR still in .packlist';
207 # unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
216 skip 'VMS install targets do not preserve $(PREFIX)', 10 if $Is_VMS;
218 $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/ VERBINST=1");
219 is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
221 like( $install_out, qr/^Installing /m );
222 like( $install_out, qr/^Writing /m );
224 ok( !-d 'elsewhere', ' install dir not created' );
225 ok( -d 'other/elsewhere', ' destdir created' );
227 find( sub { $files{$_} = $File::Find::name; }, 'other/elsewhere' );
228 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
229 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
230 ok( $files{'program'}, ' program installed' );
231 ok( $files{'.packlist'}, ' packlist created' );
232 ok( $files{'perllocal.pod'},' perllocal.pod created' );