Integrate mainline
[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;
80a5d8e7 17use Test::More tests => 17;
75e2e551 18use MakeMaker::Test::Utils;
19use File::Spec;
20use TieOut;
21
80a5d8e7 22my $perl = which_perl();
75e2e551 23
24$ENV{PERL_CORE} ? chdir '../lib/ExtUtils/t' : chdir 't';
25
26perl_lib;
27
80a5d8e7 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.
80a5d8e7 38mkdir 't' || die "Can't create test dir: $!";
75e2e551 39open(TEST, ">t/compile.t") or die "Can't open t/compile.t: $!";
80a5d8e7 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
80a5d8e7 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
80a5d8e7 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
106my $dist_test_out = `$make disttest`;
107is( $?, 0, 'disttest' ) || diag($dist_test_out);
108
80a5d8e7 109
110# Make sure init_dirscan doesn't go into the distdir
111@mpl_out = `$perl Makefile.PL "PREFIX=dummy-install"`;
112
113cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
114 diag(@mpl_out);
115
116ok( grep(/^Writing $makefile for Big::Fat::Dummy/,
117 @mpl_out) == 1,
118 'init_dirscan skipped distdir') ||
119 diag(@mpl_out);
120
121# I know we'll get ignored errors from make here, that's ok.
122# Send STDERR off to oblivion.
123open(SAVERR, ">&STDERR") or die $!;
124open(STDERR, ">".File::Spec->devnull) or die $!;
125
75e2e551 126my $realclean_out = `$make realclean`;
127is( $?, 0, 'realclean' ) || diag($realclean_out);
128
80a5d8e7 129open(STDERR, ">&SAVERR") or die $!;
130close SAVERR;