3 # This test puts MakeMaker through the paces of a basic perl module
4 # build, test and installation of the Big::Fat::Dummy module.
7 if( $ENV{PERL_CORE} ) {
9 @INC = ('../lib', 'lib');
12 unshift @INC, 't/lib';
19 use Test::More tests => 52;
20 use MakeMaker::Test::Utils;
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 chdir($Is_VMS ? 'BFD_TEST_ROOT:[t]' : 't');
36 my $Touch_Time = calibrate_mtime();
40 ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
41 diag("chdir failed: $!");
43 my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=dummy-install"});
45 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
48 my $makefile = makefile_name();
49 ok( grep(/^Writing $makefile for Big::Dummy/,
51 'Makefile.PL output looks right');
53 ok( grep(/^Current package is: main$/,
55 'Makefile.PL run in package main');
57 ok( -e $makefile, 'Makefile exists' );
60 my $mtime = (stat($makefile))[9];
61 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
63 END { unlink makefile_name(), makefile_backup() }
65 my $make = make_run();
68 # Supress 'make manifest' noise
69 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
70 my $manifest_out = run("$make manifest");
71 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
72 ok( -s 'MANIFEST', ' its not empty' );
75 END { unlink 'MANIFEST'; }
78 my $ppd_out = run("$make ppd");
79 is( $?, 0, ' exited normally' ) || diag $ppd_out;
80 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
82 { local $/; $ppd_html = <PPD> }
84 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
86 like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' );
87 like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
90 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
92 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
93 like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
95 like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
97 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m,
99 like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
100 like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
101 like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
102 END { unlink 'Big-Dummy.ppd' }
105 my $test_out = run("$make test");
106 like( $test_out, qr/All tests successful/, 'make test' );
107 is( $?, 0, ' exited normally' );
109 # Test 'make test TEST_VERBOSE=1'
110 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
111 $test_out = run("$make_test_verbose");
112 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
113 like( $test_out, qr/All tests successful/, ' successful' );
114 is( $?, 0, ' exited normally' );
117 my $install_out = run("$make install");
118 is( $?, 0, 'install' ) || diag $install_out;
119 like( $install_out, qr/^Installing /m );
120 like( $install_out, qr/^Writing /m );
122 ok( -r 'dummy-install', ' install dir created' );
125 # do it case-insensitive for non-case preserving OSs
126 $files{lc $_} = $File::Find::name;
127 }, 'dummy-install' );
128 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
129 ok( $files{'liar.pm'}, ' Liar.pm installed' );
130 ok( $files{'.packlist'}, ' packlist created' );
131 ok( $files{'perllocal.pod'},' perllocal.pod created' );
135 skip "VMS install targets do not preserve PREFIX", 8 if $Is_VMS;
137 $install_out = run("$make install PREFIX=elsewhere");
138 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
139 like( $install_out, qr/^Installing /m );
140 like( $install_out, qr/^Writing /m );
142 ok( -r 'elsewhere', ' install dir created' );
144 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
145 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
146 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
147 ok( $files{'.packlist'}, ' packlist created' );
148 ok( $files{'perllocal.pod'},' perllocal.pod created' );
152 my $dist_test_out = run("$make disttest");
153 is( $?, 0, 'disttest' ) || diag($dist_test_out);
155 # Test META.yml generation
156 use ExtUtils::Manifest qw(maniread);
157 ok( -f 'META.yml', 'META.yml written' );
158 my $manifest = maniread();
159 # VMS is non-case preserving, so we can't know what the MANIFEST will
161 _normalize($manifest);
162 is( $manifest->{'meta.yml'}, 'Module meta-data in YAML' );
164 # Test NO_META META.yml suppression
166 ok( !-f 'META.yml', 'META.yml deleted' );
167 @mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
168 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
169 my $metafile_out = run("$make metafile");
170 is( $?, 0, 'metafile' ) || diag($metafile_out);
171 ok( !-f 'META.yml', 'META.yml generation suppressed by NO_META' );
174 # Make sure init_dirscan doesn't go into the distdir
175 @mpl_out = run(qq{$perl Makefile.PL "PREFIX=dummy-install"});
177 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
179 ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
180 'init_dirscan skipped distdir') ||
183 # I know we'll get ignored errors from make here, that's ok.
184 # Send STDERR off to oblivion.
185 open(SAVERR, ">&STDERR") or die $!;
186 open(STDERR, ">".File::Spec->devnull) or die $!;
188 my $realclean_out = run("$make realclean");
189 is( $?, 0, 'realclean' ) || diag($realclean_out);
191 open(STDERR, ">&SAVERR") or die $!;
198 while(my($k,$v) = each %$hash) {