Upgrade to MakeMaker 6.10_07 (from makemaker.org snapshot
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / basic.t
CommitLineData
75e2e551 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 17use Config;
18
1df8d179 19use Test::More tests => 54;
75e2e551 20use MakeMaker::Test::Utils;
479d2113 21use File::Find;
75e2e551 22use File::Spec;
75e2e551 23
dedf98bc 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
431b0fc4 31chdir($Is_VMS ? 'BFD_TEST_ROOT:[t]' : 't');
57b1a898 32
75e2e551 33
34perl_lib;
35
e0678a30 36my $Touch_Time = calibrate_mtime();
37
75e2e551 38$| = 1;
39
45bc4d3a 40ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
75e2e551 41 diag("chdir failed: $!");
42
1df8d179 43my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
75e2e551 44
45cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
46 diag(@mpl_out);
47
48my $makefile = makefile_name();
45bc4d3a 49ok( grep(/^Writing $makefile for Big::Dummy/,
75e2e551 50 @mpl_out) == 1,
51 'Makefile.PL output looks right');
52
53ok( grep(/^Current package is: main$/,
54 @mpl_out) == 1,
55 'Makefile.PL run in package main');
56
57ok( -e $makefile, 'Makefile exists' );
58
e0678a30 59# -M is flakey on VMS
60my $mtime = (stat($makefile))[9];
61cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
75e2e551 62
63END { unlink makefile_name(), makefile_backup() }
64
65my $make = make_run();
66
67{
68 # Supress 'make manifest' noise
69 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
dedf98bc 70 my $manifest_out = run("$make manifest");
75e2e551 71 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
72 ok( -s 'MANIFEST', ' its not empty' );
73}
74
75END { unlink 'MANIFEST'; }
76
479d2113 77
dedf98bc 78my $ppd_out = run("$make ppd");
79is( $?, 0, ' exited normally' ) || diag $ppd_out;
479d2113 80ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
81my $ppd_html;
82{ local $/; $ppd_html = <PPD> }
83close PPD;
84like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
85 ' <SOFTPKG>' );
86like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' );
87like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
88 ' <ABSTRACT>');
89like( $ppd_html,
90 qr{^\s*<AUTHOR>Michael G Schwern &lt;schwern\@pobox.com&gt;</AUTHOR>}m,
91 ' <AUTHOR>' );
92like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
93like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
94 ' <DEPENDENCY>' );
95like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
96 ' <OS>' );
97like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m,
98 ' <ARCHITECTURE>');
99like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
100like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
101like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
102END { unlink 'Big-Dummy.ppd' }
103
104
dedf98bc 105my $test_out = run("$make test");
75e2e551 106like( $test_out, qr/All tests successful/, 'make test' );
479d2113 107is( $?, 0, ' exited normally' );
75e2e551 108
109# Test 'make test TEST_VERBOSE=1'
110my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
dedf98bc 111$test_out = run("$make_test_verbose");
75e2e551 112like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
479d2113 113like( $test_out, qr/All tests successful/, ' successful' );
114is( $?, 0, ' exited normally' );
115
116
dedf98bc 117my $install_out = run("$make install");
479d2113 118is( $?, 0, 'install' ) || diag $install_out;
119like( $install_out, qr/^Installing /m );
120like( $install_out, qr/^Writing /m );
121
1df8d179 122ok( -r '../dummy-install', ' install dir created' );
479d2113 123my %files = ();
124find( sub {
125 # do it case-insensitive for non-case preserving OSs
126 $files{lc $_} = $File::Find::name;
1df8d179 127}, '../dummy-install' );
479d2113 128ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
129ok( $files{'liar.pm'}, ' Liar.pm installed' );
130ok( $files{'.packlist'}, ' packlist created' );
131ok( $files{'perllocal.pod'},' perllocal.pod created' );
132
133
134SKIP: {
135 skip "VMS install targets do not preserve PREFIX", 8 if $Is_VMS;
136
dedf98bc 137 $install_out = run("$make install PREFIX=elsewhere");
479d2113 138 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
139 like( $install_out, qr/^Installing /m );
140 like( $install_out, qr/^Writing /m );
141
142 ok( -r 'elsewhere', ' install dir created' );
143 %files = ();
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' );
149}
150
75e2e551 151
dedf98bc 152my $dist_test_out = run("$make disttest");
75e2e551 153is( $?, 0, 'disttest' ) || diag($dist_test_out);
154
479d2113 155# Test META.yml generation
156use ExtUtils::Manifest qw(maniread);
157ok( -f 'META.yml', 'META.yml written' );
158my $manifest = maniread();
159# VMS is non-case preserving, so we can't know what the MANIFEST will
160# look like. :(
161_normalize($manifest);
2530b651 162is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
479d2113 163
431b0fc4 164# Test NO_META META.yml suppression
165unlink 'META.yml';
166ok( !-f 'META.yml', 'META.yml deleted' );
167@mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
168cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
169my $metafile_out = run("$make metafile");
170is( $?, 0, 'metafile' ) || diag($metafile_out);
171ok( !-f 'META.yml', 'META.yml generation suppressed by NO_META' );
172
1df8d179 173# Test if MANIFEST is read-only.
174chmod 0444, 'MANIFEST';
175@mpl_out = run(qq{$perl Makefile.PL});
176cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
177$metafile_out = run("$make metafile_addtomanifest");
178is( $?, 0, q{metafile_addtomanifest didn't die with locked MANIFEST} ) ||
179 diag($metafile_out);
180
e0678a30 181
182# Make sure init_dirscan doesn't go into the distdir
1df8d179 183@mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
e0678a30 184
431b0fc4 185cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
e0678a30 186
479d2113 187ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
e0678a30 188 'init_dirscan skipped distdir') ||
189 diag(@mpl_out);
190
191# I know we'll get ignored errors from make here, that's ok.
192# Send STDERR off to oblivion.
193open(SAVERR, ">&STDERR") or die $!;
194open(STDERR, ">".File::Spec->devnull) or die $!;
195
dedf98bc 196my $realclean_out = run("$make realclean");
75e2e551 197is( $?, 0, 'realclean' ) || diag($realclean_out);
198
e0678a30 199open(STDERR, ">&SAVERR") or die $!;
200close SAVERR;
479d2113 201
202
203sub _normalize {
204 my $hash = shift;
205
206 while(my($k,$v) = each %$hash) {
207 delete $hash->{$k};
208 $hash->{lc $k} = $v;
209 }
210}