Undo #16091, a time-warped escapee.
[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;
e0678a30 17use Test::More tests => 17;
75e2e551 18use MakeMaker::Test::Utils;
19use File::Spec;
20use TieOut;
21
e0678a30 22my $perl = which_perl();
75e2e551 23
24$ENV{PERL_CORE} ? chdir '../lib/ExtUtils/t' : chdir 't';
25
26perl_lib;
27
e0678a30 28my $Touch_Time = calibrate_mtime();
29
75e2e551 30$| = 1;
31
32ok( chdir 'Big-Fat-Dummy', "chdir'd to Big-Fat-Dummy" ) ||
33 diag("chdir failed: $!");
34
35
36# The perl core test suite will run any .t file in the MANIFEST.
37# So we have to generate this on the fly.
e0678a30 38mkdir 't' || die "Can't create test dir: $!";
75e2e551 39open(TEST, ">t/compile.t") or die "Can't open t/compile.t: $!";
e0678a30 40print TEST <<'COMPILE_T';
41print "1..2\n";
42
43print eval "use Big::Fat::Dummy; 1;" ? "ok 1\n" : "not ok 1\n";
44print "ok 2 - TEST_VERBOSE\n";
45COMPILE_T
75e2e551 46close TEST;
47
e0678a30 48mkdir 'Liar/t' || die "Can't create test dir: $!";
49open(TEST, ">Liar/t/sanity.t") or die "Can't open Liar/t/sanity.t: $!";
50print TEST <<'SANITY_T';
51print "1..3\n";
52
53print eval "use Big::Fat::Dummy; 1;" ? "ok 1\n" : "not ok 1\n";
54print eval "use Big::Fat::Liar; 1;" ? "ok 2\n" : "not ok 2\n";
55print "ok 3 - TEST_VERBOSE\n";
56SANITY_T
57close TEST;
58
59END { unlink 't/compile.t', 'Liar/t/sanity.t' }
75e2e551 60
61my @mpl_out = `$perl Makefile.PL PREFIX=dummy-install`;
62
63cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
64 diag(@mpl_out);
65
66my $makefile = makefile_name();
67ok( grep(/^Writing $makefile for Big::Fat::Dummy/,
68 @mpl_out) == 1,
69 'Makefile.PL output looks right');
70
71ok( grep(/^Current package is: main$/,
72 @mpl_out) == 1,
73 'Makefile.PL run in package main');
74
75ok( -e $makefile, 'Makefile exists' );
76
e0678a30 77# -M is flakey on VMS
78my $mtime = (stat($makefile))[9];
79cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
75e2e551 80
81END { unlink makefile_name(), makefile_backup() }
82
83my $make = make_run();
84
85{
86 # Supress 'make manifest' noise
87 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
88 my $manifest_out = `$make manifest`;
89 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
90 ok( -s 'MANIFEST', ' its not empty' );
91}
92
93END { unlink 'MANIFEST'; }
94
95my $test_out = `$make test`;
96like( $test_out, qr/All tests successful/, 'make test' );
97is( $?, 0 );
98
99# Test 'make test TEST_VERBOSE=1'
100my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
101$test_out = `$make_test_verbose`;
102like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
103like( $test_out, qr/All tests successful/, ' successful' );
104is( $?, 0 );
105
c623ac67 106my $kill_err = $^O eq 'MSWin32' ? '2>&1' : ''; # avoid nmake spew
107my $dist_test_out = `$make disttest $kill_err`;
75e2e551 108is( $?, 0, 'disttest' ) || diag($dist_test_out);
109
e0678a30 110
111# Make sure init_dirscan doesn't go into the distdir
112@mpl_out = `$perl Makefile.PL "PREFIX=dummy-install"`;
113
114cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
115 diag(@mpl_out);
116
117ok( grep(/^Writing $makefile for Big::Fat::Dummy/,
118 @mpl_out) == 1,
119 'init_dirscan skipped distdir') ||
120 diag(@mpl_out);
121
122# I know we'll get ignored errors from make here, that's ok.
123# Send STDERR off to oblivion.
124open(SAVERR, ">&STDERR") or die $!;
125open(STDERR, ">".File::Spec->devnull) or die $!;
126
75e2e551 127my $realclean_out = `$make realclean`;
128is( $?, 0, 'realclean' ) || diag($realclean_out);
129
e0678a30 130open(STDERR, ">&SAVERR") or die $!;
131close SAVERR;