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 # This test puts MakeMaker through the paces of a basic perl module
8 # build, test and installation of the Big::Fat::Dummy module.
12 use ExtUtils::MakeMaker;
14 use Test::More tests => $::TESTS;
15 use MakeMaker::Test::Utils;
16 use MakeMaker::Test::Setup::BFD;
21 # 'make disttest' sets a bunch of environment variables which interfere
23 delete @ENV{qw(PREFIX LIB MAKEFLAGS)};
25 my $perl = which_perl();
26 my $Is_VMS = $^O eq 'VMS';
28 # GNV logical interferes with testing
29 $ENV{'bin'} = '[.bin]' if $Is_VMS;
35 my $Touch_Time = calibrate_mtime();
39 ok( setup_recurs(), 'setup' );
41 ok( chdir File::Spec->updir );
42 ok( teardown_recurs(), 'teardown' );
45 ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
46 diag("chdir failed: $!");
48 my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
49 END { rmtree '../dummy-install'; }
51 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
54 my $makefile = makefile_name();
55 ok( grep(/^Writing $makefile for Big::Dummy/,
57 'Makefile.PL output looks right');
59 ok( grep(/^Current package is: main$/,
61 'Makefile.PL run in package main');
63 ok( -e $makefile, 'Makefile exists' );
66 my $mtime = (stat($makefile))[9];
67 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
69 END { unlink makefile_name(), makefile_backup() }
71 my $make = make_run();
74 # Supress 'make manifest' noise
75 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
76 my $manifest_out = run("$make manifest");
77 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
78 ok( -s 'MANIFEST', ' its not empty' );
81 END { unlink 'MANIFEST'; }
83 unless ($::TEST_INSTALL_ONLY) {
84 my $ppd_out = run("$make ppd");
85 is( $?, 0, ' exited normally' ) || diag $ppd_out;
86 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
88 { local $/; $ppd_html = <PPD> }
90 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
92 like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' );
93 like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m, # Unconfuse highlighters: '
96 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
98 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
99 like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
101 like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
103 my $archname = $Config{archname};
104 $archname .= "-". substr($Config{version},0,3) if $] >= 5.008;
105 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$archname" />}m,
107 like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
108 like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
109 like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
110 END { unlink 'Big-Dummy.ppd' }
113 my $test_out = run("$make test");
114 like( $test_out, qr/All tests successful/, 'make test' );
115 is( $?, 0, ' exited normally' ) ||
118 # Test 'make test TEST_VERBOSE=1'
119 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
120 $test_out = run("$make_test_verbose");
121 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
122 like( $test_out, qr/All tests successful/, ' successful' );
123 is( $?, 0, ' exited normally' ) ||
126 # Test 'make install VERBINST=1'
127 my $make_install_verbinst = make_macro($make, 'install', VERBINST => 1);
128 my $install_out = run($make_install_verbinst);
129 is( $?, 0, 'install' ) || diag $install_out;
130 like( $install_out, qr/^Installing /m );
131 like( $install_out, qr/^Writing /m );
133 ok( -r '../dummy-install', ' install dir created' );
136 # do it case-insensitive for non-case preserving OSs
139 # VMS likes to put dots on the end of things that don't have them.
140 $file =~ s/\.$// if $Is_VMS;
142 $files{$file} = $File::Find::name;
143 }, '../dummy-install' );
144 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
145 ok( $files{'liar.pm'}, ' Liar.pm installed' );
146 ok( $files{'program'}, ' program installed' );
147 ok( $files{'.packlist'}, ' packlist created' );
148 ok( $files{'perllocal.pod'},' perllocal.pod created' );
152 skip 'VMS install targets do not preserve $(PREFIX)', 9 if $Is_VMS;
154 $install_out = run("$make install PREFIX=elsewhere VERBINST=1");
155 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
156 like( $install_out, qr/^Installing /m );
157 like( $install_out, qr/^Writing /m );
159 ok( -r 'elsewhere', ' install dir created' );
161 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
162 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
163 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
164 ok( $files{'program'}, ' program installed' );
165 ok( $files{'.packlist'}, ' packlist created' );
166 ok( $files{'perllocal.pod'},' perllocal.pod created' );
172 skip 'VMS install targets do not preserve $(DESTDIR)', 11 if $Is_VMS;
174 $install_out = run("$make install PREFIX= DESTDIR=other VERBINST=1");
175 is( $?, 0, 'install with DESTDIR' ) ||
177 like( $install_out, qr/^Installing /m );
178 like( $install_out, qr/^Writing /m );
180 ok( -d 'other', ' destdir created' );
184 $files{$_} = $File::Find::name;
186 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
187 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
188 ok( $files{'program'}, ' program installed' );
189 ok( $files{'.packlist'}, ' packlist created' );
190 ok( $files{'perllocal.pod'},' perllocal.pod created' );
192 ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
193 diag("Can't open $files{'perllocal.pod'}: $!");
195 unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
199 # TODO not available in the min version of Test::Harness we require
200 # ok( open(PACKLIST, $files{'.packlist'} ) ) ||
201 # diag("Can't open $files{'.packlist'}: $!");
203 # local $TODO = 'DESTDIR still in .packlist';
204 # unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
213 skip 'VMS install targets do not preserve $(PREFIX)', 10 if $Is_VMS;
215 $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/ VERBINST=1");
216 is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
218 like( $install_out, qr/^Installing /m );
219 like( $install_out, qr/^Writing /m );
221 ok( !-d 'elsewhere', ' install dir not created' );
222 ok( -d 'other/elsewhere', ' destdir created' );
224 find( sub { $files{$_} = $File::Find::name; }, 'other/elsewhere' );
225 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
226 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
227 ok( $files{'program'}, ' program installed' );
228 ok( $files{'.packlist'}, ' packlist created' );
229 ok( $files{'perllocal.pod'},' perllocal.pod created' );