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 => 48;
20 use MakeMaker::Test::Utils;
24 my $perl = which_perl();
25 my $Is_VMS = $^O eq 'VMS';
30 # On older systems we might exceed the 8-level directory depth limit
31 # imposed by RMS. We get around this with a rooted logical, but we
32 # can't create logical names with attributes in Perl, so we do it
33 # in a DCL subprocess and put it in the job table so the parent sees it.
34 open( BFDTMP, '>bfdtesttmp.com' ) || die "Error creating command file; $!";
35 print BFDTMP <<'COMMAND';
36 $ IF F$TRNLNM("PERL_CORE") .EQS. "" .AND. F$TYPE(PERL_CORE) .EQS. ""
38 $! building CPAN version
39 $ BFD_TEST_ROOT = F$PARSE("SYS$DISK:[]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
42 $ BFD_TEST_ROOT = F$PARSE("SYS$DISK:[-]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
44 $ DEFINE/JOB/NOLOG/TRANSLATION=CONCEALED BFD_TEST_ROOT 'BFD_TEST_ROOT'
48 system '@bfdtesttmp.com';
49 END { 1 while unlink 'bfdtesttmp.com' }
50 $root_dir = 'BFD_TEST_ROOT:[t]';
58 my $Touch_Time = calibrate_mtime();
62 ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
63 diag("chdir failed: $!");
65 my @mpl_out = `$perl Makefile.PL PREFIX=dummy-install`;
67 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
70 my $makefile = makefile_name();
71 ok( grep(/^Writing $makefile for Big::Dummy/,
73 'Makefile.PL output looks right');
75 ok( grep(/^Current package is: main$/,
77 'Makefile.PL run in package main');
79 ok( -e $makefile, 'Makefile exists' );
82 my $mtime = (stat($makefile))[9];
83 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
85 END { unlink makefile_name(), makefile_backup() }
87 my $make = make_run();
90 # Supress 'make manifest' noise
91 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
92 my $manifest_out = `$make manifest`;
93 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
94 ok( -s 'MANIFEST', ' its not empty' );
97 END { unlink 'MANIFEST'; }
101 is( $?, 0, ' exited normally' );
102 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
104 { local $/; $ppd_html = <PPD> }
106 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
108 like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' );
109 like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
112 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
114 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
115 like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
117 like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
119 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m,
121 like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
122 like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
123 like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
124 END { unlink 'Big-Dummy.ppd' }
127 my $test_out = `$make test`;
128 like( $test_out, qr/All tests successful/, 'make test' );
129 is( $?, 0, ' exited normally' );
131 # Test 'make test TEST_VERBOSE=1'
132 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
133 $test_out = `$make_test_verbose`;
134 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
135 like( $test_out, qr/All tests successful/, ' successful' );
136 is( $?, 0, ' exited normally' );
139 my $install_out = `$make install`;
140 is( $?, 0, 'install' ) || diag $install_out;
141 like( $install_out, qr/^Installing /m );
142 like( $install_out, qr/^Writing /m );
144 ok( -r 'dummy-install', ' install dir created' );
147 # do it case-insensitive for non-case preserving OSs
148 $files{lc $_} = $File::Find::name;
149 }, 'dummy-install' );
150 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
151 ok( $files{'liar.pm'}, ' Liar.pm installed' );
152 ok( $files{'.packlist'}, ' packlist created' );
153 ok( $files{'perllocal.pod'},' perllocal.pod created' );
157 skip "VMS install targets do not preserve PREFIX", 8 if $Is_VMS;
159 $install_out = `$make install PREFIX=elsewhere`;
160 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
161 like( $install_out, qr/^Installing /m );
162 like( $install_out, qr/^Writing /m );
164 ok( -r 'elsewhere', ' install dir created' );
166 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
167 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
168 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
169 ok( $files{'.packlist'}, ' packlist created' );
170 ok( $files{'perllocal.pod'},' perllocal.pod created' );
174 my $dist_test_out = `$make disttest`;
175 is( $?, 0, 'disttest' ) || diag($dist_test_out);
177 # Test META.yml generation
178 use ExtUtils::Manifest qw(maniread);
179 ok( -f 'META.yml', 'META.yml written' );
180 my $manifest = maniread();
181 # VMS is non-case preserving, so we can't know what the MANIFEST will
183 _normalize($manifest);
184 is( $manifest->{'meta.yml'}, 'Module meta-data in YAML' );
187 # Make sure init_dirscan doesn't go into the distdir
188 @mpl_out = `$perl Makefile.PL "PREFIX=dummy-install"`;
190 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
193 ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
194 'init_dirscan skipped distdir') ||
197 # I know we'll get ignored errors from make here, that's ok.
198 # Send STDERR off to oblivion.
199 open(SAVERR, ">&STDERR") or die $!;
200 open(STDERR, ">".File::Spec->devnull) or die $!;
202 my $realclean_out = `$make realclean`;
203 is( $?, 0, 'realclean' ) || diag($realclean_out);
205 open(STDERR, ">&SAVERR") or die $!;
212 while(my($k,$v) = each %$hash) {