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 # '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';
34 # On older systems we might exceed the 8-level directory depth limit
35 # imposed by RMS. We get around this with a rooted logical, but we
36 # can't create logical names with attributes in Perl, so we do it
37 # in a DCL subprocess and put it in the job table so the parent sees it.
38 open( BFDTMP, '>bfdtesttmp.com' ) || die "Error creating command file; $!";
39 print BFDTMP <<'COMMAND';
40 $ IF F$TRNLNM("PERL_CORE") .EQS. "" .AND. F$TYPE(PERL_CORE) .EQS. ""
42 $! building CPAN version
43 $ BFD_TEST_ROOT = F$PARSE("SYS$DISK:[]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
46 $ BFD_TEST_ROOT = F$PARSE("SYS$DISK:[-]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
48 $ DEFINE/JOB/NOLOG/TRANSLATION=CONCEALED BFD_TEST_ROOT 'BFD_TEST_ROOT'
52 system '@bfdtesttmp.com';
53 END { 1 while unlink 'bfdtesttmp.com' }
54 $root_dir = 'BFD_TEST_ROOT:[t]';
62 my $Touch_Time = calibrate_mtime();
66 ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
67 diag("chdir failed: $!");
69 my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=dummy-install"});
71 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
74 my $makefile = makefile_name();
75 ok( grep(/^Writing $makefile for Big::Dummy/,
77 'Makefile.PL output looks right');
79 ok( grep(/^Current package is: main$/,
81 'Makefile.PL run in package main');
83 ok( -e $makefile, 'Makefile exists' );
86 my $mtime = (stat($makefile))[9];
87 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
89 END { unlink makefile_name(), makefile_backup() }
91 my $make = make_run();
94 # Supress 'make manifest' noise
95 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
96 my $manifest_out = run("$make manifest");
97 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
98 ok( -s 'MANIFEST', ' its not empty' );
101 END { unlink 'MANIFEST'; }
104 my $ppd_out = run("$make ppd");
105 is( $?, 0, ' exited normally' ) || diag $ppd_out;
106 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
108 { local $/; $ppd_html = <PPD> }
110 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
112 like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' );
113 like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
116 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
118 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
119 like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
121 like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
123 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m,
125 like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
126 like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
127 like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
128 END { unlink 'Big-Dummy.ppd' }
131 my $test_out = run("$make test");
132 like( $test_out, qr/All tests successful/, 'make test' );
133 is( $?, 0, ' exited normally' );
135 # Test 'make test TEST_VERBOSE=1'
136 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
137 $test_out = run("$make_test_verbose");
138 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
139 like( $test_out, qr/All tests successful/, ' successful' );
140 is( $?, 0, ' exited normally' );
143 my $install_out = run("$make install");
144 is( $?, 0, 'install' ) || diag $install_out;
145 like( $install_out, qr/^Installing /m );
146 like( $install_out, qr/^Writing /m );
148 ok( -r 'dummy-install', ' install dir created' );
151 # do it case-insensitive for non-case preserving OSs
152 $files{lc $_} = $File::Find::name;
153 }, 'dummy-install' );
154 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
155 ok( $files{'liar.pm'}, ' Liar.pm installed' );
156 ok( $files{'.packlist'}, ' packlist created' );
157 ok( $files{'perllocal.pod'},' perllocal.pod created' );
161 skip "VMS install targets do not preserve PREFIX", 8 if $Is_VMS;
163 $install_out = run("$make install PREFIX=elsewhere");
164 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
165 like( $install_out, qr/^Installing /m );
166 like( $install_out, qr/^Writing /m );
168 ok( -r 'elsewhere', ' install dir created' );
170 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
171 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
172 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
173 ok( $files{'.packlist'}, ' packlist created' );
174 ok( $files{'perllocal.pod'},' perllocal.pod created' );
178 my $dist_test_out = run("$make disttest");
179 is( $?, 0, 'disttest' ) || diag($dist_test_out);
181 # Test META.yml generation
182 use ExtUtils::Manifest qw(maniread);
183 ok( -f 'META.yml', 'META.yml written' );
184 my $manifest = maniread();
185 # VMS is non-case preserving, so we can't know what the MANIFEST will
187 _normalize($manifest);
188 is( $manifest->{'meta.yml'}, 'Module meta-data in YAML' );
191 # Make sure init_dirscan doesn't go into the distdir
192 @mpl_out = run(qq{$perl Makefile.PL "PREFIX=dummy-install"});
194 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
197 ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
198 'init_dirscan skipped distdir') ||
201 # I know we'll get ignored errors from make here, that's ok.
202 # Send STDERR off to oblivion.
203 open(SAVERR, ">&STDERR") or die $!;
204 open(STDERR, ">".File::Spec->devnull) or die $!;
206 my $realclean_out = run("$make realclean");
207 is( $?, 0, 'realclean' ) || diag($realclean_out);
209 open(STDERR, ">&SAVERR") or die $!;
216 while(my($k,$v) = each %$hash) {