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