This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH] ExtUtils::MakeMaker 6.10_02
[perl5.git] / lib / ExtUtils / t / basic.t
CommitLineData
75e2e551
MS
1#!/usr/bin/perl -w
2
3# This test puts MakeMaker through the paces of a basic perl module
4# build, test and installation of the Big::Fat::Dummy module.
5
6BEGIN {
7 if( $ENV{PERL_CORE} ) {
8 chdir 't' if -d 't';
9 @INC = ('../lib', 'lib');
10 }
11 else {
12 unshift @INC, 't/lib';
13 }
14}
15
16use strict;
479d2113
MS
17use Config;
18
19use Test::More tests => 48;
75e2e551 20use MakeMaker::Test::Utils;
479d2113 21use File::Find;
75e2e551 22use File::Spec;
75e2e551 23
dedf98bc
MS
24# 'make disttest' sets a bunch of environment variables which interfere
25# with our testing.
26delete @ENV{qw(PREFIX LIB MAKEFLAGS)};
27
e0678a30 28my $perl = which_perl();
479d2113 29my $Is_VMS = $^O eq 'VMS';
75e2e551 30
57b1a898
MS
31my $root_dir = 't';
32
33if( $^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';
a67d7a01
MS
40$ IF F$TRNLNM("PERL_CORE") .EQS. "" .AND. F$TYPE(PERL_CORE) .EQS. ""
41$ THEN
42$! building CPAN version
7a069417 43$ BFD_TEST_ROOT = F$PARSE("SYS$DISK:[]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
a67d7a01
MS
44$ ELSE
45$! we're in the core
7a069417 46$ BFD_TEST_ROOT = F$PARSE("SYS$DISK:[-]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
a67d7a01 47$ ENDIF
57b1a898
MS
48$ DEFINE/JOB/NOLOG/TRANSLATION=CONCEALED BFD_TEST_ROOT 'BFD_TEST_ROOT'
49COMMAND
50 close BFDTMP;
51
52 system '@bfdtesttmp.com';
53 END { 1 while unlink 'bfdtesttmp.com' }
7a069417 54 $root_dir = 'BFD_TEST_ROOT:[t]';
57b1a898
MS
55}
56
57chdir $root_dir;
58
75e2e551
MS
59
60perl_lib;
61
e0678a30
MS
62my $Touch_Time = calibrate_mtime();
63
75e2e551
MS
64$| = 1;
65
45bc4d3a 66ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
75e2e551
MS
67 diag("chdir failed: $!");
68
dedf98bc 69my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=dummy-install"});
75e2e551
MS
70
71cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
72 diag(@mpl_out);
73
74my $makefile = makefile_name();
45bc4d3a 75ok( grep(/^Writing $makefile for Big::Dummy/,
75e2e551
MS
76 @mpl_out) == 1,
77 'Makefile.PL output looks right');
78
79ok( grep(/^Current package is: main$/,
80 @mpl_out) == 1,
81 'Makefile.PL run in package main');
82
83ok( -e $makefile, 'Makefile exists' );
84
e0678a30
MS
85# -M is flakey on VMS
86my $mtime = (stat($makefile))[9];
87cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
75e2e551
MS
88
89END { unlink makefile_name(), makefile_backup() }
90
91my $make = make_run();
92
93{
94 # Supress 'make manifest' noise
95 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
dedf98bc 96 my $manifest_out = run("$make manifest");
75e2e551
MS
97 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
98 ok( -s 'MANIFEST', ' its not empty' );
99}
100
101END { unlink 'MANIFEST'; }
102
479d2113 103
dedf98bc
MS
104my $ppd_out = run("$make ppd");
105is( $?, 0, ' exited normally' ) || diag $ppd_out;
479d2113
MS
106ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
107my $ppd_html;
108{ local $/; $ppd_html = <PPD> }
109close PPD;
110like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
111 ' <SOFTPKG>' );
112like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' );
113like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
114 ' <ABSTRACT>');
115like( $ppd_html,
116 qr{^\s*<AUTHOR>Michael G Schwern &lt;schwern\@pobox.com&gt;</AUTHOR>}m,
117 ' <AUTHOR>' );
118like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
119like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
120 ' <DEPENDENCY>' );
121like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
122 ' <OS>' );
123like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m,
124 ' <ARCHITECTURE>');
125like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
126like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
127like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
128END { unlink 'Big-Dummy.ppd' }
129
130
dedf98bc 131my $test_out = run("$make test");
75e2e551 132like( $test_out, qr/All tests successful/, 'make test' );
479d2113 133is( $?, 0, ' exited normally' );
75e2e551
MS
134
135# Test 'make test TEST_VERBOSE=1'
136my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
dedf98bc 137$test_out = run("$make_test_verbose");
75e2e551 138like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
479d2113
MS
139like( $test_out, qr/All tests successful/, ' successful' );
140is( $?, 0, ' exited normally' );
141
142
dedf98bc 143my $install_out = run("$make install");
479d2113
MS
144is( $?, 0, 'install' ) || diag $install_out;
145like( $install_out, qr/^Installing /m );
146like( $install_out, qr/^Writing /m );
147
148ok( -r 'dummy-install', ' install dir created' );
149my %files = ();
150find( sub {
151 # do it case-insensitive for non-case preserving OSs
152 $files{lc $_} = $File::Find::name;
153}, 'dummy-install' );
154ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
155ok( $files{'liar.pm'}, ' Liar.pm installed' );
156ok( $files{'.packlist'}, ' packlist created' );
157ok( $files{'perllocal.pod'},' perllocal.pod created' );
158
159
160SKIP: {
161 skip "VMS install targets do not preserve PREFIX", 8 if $Is_VMS;
162
dedf98bc 163 $install_out = run("$make install PREFIX=elsewhere");
479d2113
MS
164 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
165 like( $install_out, qr/^Installing /m );
166 like( $install_out, qr/^Writing /m );
167
168 ok( -r 'elsewhere', ' install dir created' );
169 %files = ();
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' );
175}
176
75e2e551 177
dedf98bc 178my $dist_test_out = run("$make disttest");
75e2e551
MS
179is( $?, 0, 'disttest' ) || diag($dist_test_out);
180
479d2113
MS
181# Test META.yml generation
182use ExtUtils::Manifest qw(maniread);
183ok( -f 'META.yml', 'META.yml written' );
184my $manifest = maniread();
185# VMS is non-case preserving, so we can't know what the MANIFEST will
186# look like. :(
187_normalize($manifest);
188is( $manifest->{'meta.yml'}, 'Module meta-data in YAML' );
189
e0678a30
MS
190
191# Make sure init_dirscan doesn't go into the distdir
dedf98bc 192@mpl_out = run(qq{$perl Makefile.PL "PREFIX=dummy-install"});
e0678a30
MS
193
194cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
195 diag(@mpl_out);
196
479d2113 197ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
e0678a30
MS
198 'init_dirscan skipped distdir') ||
199 diag(@mpl_out);
200
201# I know we'll get ignored errors from make here, that's ok.
202# Send STDERR off to oblivion.
203open(SAVERR, ">&STDERR") or die $!;
204open(STDERR, ">".File::Spec->devnull) or die $!;
205
dedf98bc 206my $realclean_out = run("$make realclean");
75e2e551
MS
207is( $?, 0, 'realclean' ) || diag($realclean_out);
208
e0678a30
MS
209open(STDERR, ">&SAVERR") or die $!;
210close SAVERR;
479d2113
MS
211
212
213sub _normalize {
214 my $hash = shift;
215
216 while(my($k,$v) = each %$hash) {
217 delete $hash->{$k};
218 $hash->{lc $k} = $v;
219 }
220}