MakeMaker sync 5.48_03 -> 5.53_01
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / basic.t
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
6 BEGIN {
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 $ENV{PERL_CORE} ? chdir '../lib/ExtUtils/t' : chdir 't';
16
17 use strict;
18 use Test::More tests => 15;
19 use MakeMaker::Test::Utils;
20 use File::Spec;
21 use TieOut;
22
23 my $perl = which_perl;
24 perl_lib;
25
26 $| = 1;
27
28 ok( chdir 'Big-Fat-Dummy', "chdir'd to Big-Fat-Dummy" ) ||
29   diag("chdir failed: $!");
30
31 my @mpl_out = `$perl Makefile.PL PREFIX=dummy-install`;
32
33 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
34   diag(@mpl_out);
35
36 my $makefile = makefile_name();
37 ok( grep(/^Writing $makefile for Big::Fat::Dummy/, 
38          @mpl_out) == 1,
39                                            'Makefile.PL output looks right');
40
41 ok( grep(/^Current package is: main$/,
42          @mpl_out) == 1,
43                                            'Makefile.PL run in package main');
44
45 ok( -e $makefile,       'Makefile exists' );
46
47 # -M is flakey on VMS.
48 my $mtime = (stat($makefile))[9];
49 ok( ($^T - $mtime) <= 0,  '  its been touched' );
50
51 END { unlink makefile_name(), makefile_backup() }
52
53 # Supress 'make manifest' noise
54 open(SAVERR, ">&STDERR") || die $!;
55 close(STDERR);
56 my $make = make_run();
57 my $manifest_out = `$make manifest`;
58 ok( -e 'MANIFEST',      'make manifest created a MANIFEST' );
59 ok( -s 'MANIFEST',      '  its not empty' );
60 open(STDERR, ">&SAVERR") || die $!;
61
62 END { unlink 'MANIFEST'; }
63
64 my $test_out = `$make test`;
65 like( $test_out, qr/All tests successful/, 'make test' );
66 is( $?, 0 );
67
68 # Test 'make test TEST_VERBOSE=1'
69 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
70 $test_out = `$make_test_verbose`;
71 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
72 like( $test_out, qr/All tests successful/, '  successful' );
73 is( $?, 0 );
74
75 my $dist_test_out = `$make disttest`;
76 is( $?, 0, 'disttest' ) || diag($dist_test_out);
77
78 my $realclean_out = `$make realclean`;
79 is( $?, 0, 'realclean' ) || diag($realclean_out);
80
81 close SAVERR;