Integrate mailine
[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
57b1a898 24my $root_dir = 't';
25
26if( $^O eq 'VMS' ) {
27 # On older systems we might exceed the 8-level directory depth limit
28 # imposed by RMS. We get around this with a rooted logical, but we
29 # can't create logical names with attributes in Perl, so we do it
30 # in a DCL subprocess and put it in the job table so the parent sees it.
31 open( BFDTMP, '>bfdtesttmp.com' ) || die "Error creating command file; $!";
32 print BFDTMP <<'COMMAND';
33$ BFD_TEST_ROOT = F$PARSE("[.t]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
34$ DEFINE/JOB/NOLOG/TRANSLATION=CONCEALED BFD_TEST_ROOT 'BFD_TEST_ROOT'
35COMMAND
36 close BFDTMP;
37
38 system '@bfdtesttmp.com';
39 END { 1 while unlink 'bfdtesttmp.com' }
40 $root_dir = 'BFD_TEST_ROOT:[000000]';
41}
42
43chdir $root_dir;
44
75e2e551 45
46perl_lib;
47
e0678a30 48my $Touch_Time = calibrate_mtime();
49
75e2e551 50$| = 1;
51
45bc4d3a 52ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
75e2e551 53 diag("chdir failed: $!");
54
75e2e551 55my @mpl_out = `$perl Makefile.PL PREFIX=dummy-install`;
56
57cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
58 diag(@mpl_out);
59
60my $makefile = makefile_name();
45bc4d3a 61ok( grep(/^Writing $makefile for Big::Dummy/,
75e2e551 62 @mpl_out) == 1,
63 'Makefile.PL output looks right');
64
65ok( grep(/^Current package is: main$/,
66 @mpl_out) == 1,
67 'Makefile.PL run in package main');
68
69ok( -e $makefile, 'Makefile exists' );
70
e0678a30 71# -M is flakey on VMS
72my $mtime = (stat($makefile))[9];
73cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
75e2e551 74
75END { unlink makefile_name(), makefile_backup() }
76
77my $make = make_run();
78
79{
80 # Supress 'make manifest' noise
81 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
82 my $manifest_out = `$make manifest`;
83 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
84 ok( -s 'MANIFEST', ' its not empty' );
85}
86
87END { unlink 'MANIFEST'; }
88
89my $test_out = `$make test`;
90like( $test_out, qr/All tests successful/, 'make test' );
91is( $?, 0 );
92
93# Test 'make test TEST_VERBOSE=1'
94my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
95$test_out = `$make_test_verbose`;
96like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
97like( $test_out, qr/All tests successful/, ' successful' );
98is( $?, 0 );
99
45bc4d3a 100my $dist_test_out = `$make disttest`;
75e2e551 101is( $?, 0, 'disttest' ) || diag($dist_test_out);
102
e0678a30 103
104# Make sure init_dirscan doesn't go into the distdir
105@mpl_out = `$perl Makefile.PL "PREFIX=dummy-install"`;
106
107cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
108 diag(@mpl_out);
109
45bc4d3a 110ok( grep(/^Writing $makefile for Big::Dummy/,
e0678a30 111 @mpl_out) == 1,
112 'init_dirscan skipped distdir') ||
113 diag(@mpl_out);
114
115# I know we'll get ignored errors from make here, that's ok.
116# Send STDERR off to oblivion.
117open(SAVERR, ">&STDERR") or die $!;
118open(STDERR, ">".File::Spec->devnull) or die $!;
119
75e2e551 120my $realclean_out = `$make realclean`;
121is( $?, 0, 'realclean' ) || diag($realclean_out);
122
e0678a30 123open(STDERR, ">&SAVERR") or die $!;
124close SAVERR;