Windows 64-bit support:
[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
16 use strict;
17 use Test::More tests => 17;
18 use MakeMaker::Test::Utils;
19 use File::Spec;
20 use TieOut;
21
22 my $perl = which_perl();
23
24 $ENV{PERL_CORE} ? chdir '../lib/ExtUtils/t' : chdir 't';
25
26 perl_lib;
27
28 my $Touch_Time = calibrate_mtime();
29
30 $| = 1;
31
32 ok( 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.
38 mkdir 't' || die "Can't create test dir: $!";
39 open(TEST, ">t/compile.t") or die "Can't open t/compile.t: $!";
40 print TEST <<'COMPILE_T';
41 print "1..2\n";
42
43 print eval "use Big::Fat::Dummy; 1;" ? "ok 1\n" : "not ok 1\n";
44 print "ok 2 - TEST_VERBOSE\n";
45 COMPILE_T
46 close TEST;
47
48 mkdir 'Liar/t' || die "Can't create test dir: $!";
49 open(TEST, ">Liar/t/sanity.t") or die "Can't open Liar/t/sanity.t: $!";
50 print TEST <<'SANITY_T';
51 print "1..3\n";
52
53 print eval "use Big::Fat::Dummy; 1;" ? "ok 1\n" : "not ok 1\n";
54 print eval "use Big::Fat::Liar; 1;" ? "ok 2\n" : "not ok 2\n";
55 print "ok 3 - TEST_VERBOSE\n";
56 SANITY_T
57 close TEST;
58
59 END { unlink 't/compile.t', 'Liar/t/sanity.t' }
60
61 my @mpl_out = `$perl Makefile.PL PREFIX=dummy-install`;
62
63 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
64   diag(@mpl_out);
65
66 my $makefile = makefile_name();
67 ok( grep(/^Writing $makefile for Big::Fat::Dummy/, 
68          @mpl_out) == 1,
69                                            'Makefile.PL output looks right');
70
71 ok( grep(/^Current package is: main$/,
72          @mpl_out) == 1,
73                                            'Makefile.PL run in package main');
74
75 ok( -e $makefile,       'Makefile exists' );
76
77 # -M is flakey on VMS
78 my $mtime = (stat($makefile))[9];
79 cmp_ok( $Touch_Time, '<=', $mtime,  '  its been touched' );
80
81 END { unlink makefile_name(), makefile_backup() }
82
83 my $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
93 END { unlink 'MANIFEST'; }
94
95 my $test_out = `$make test`;
96 like( $test_out, qr/All tests successful/, 'make test' );
97 is( $?, 0 );
98
99 # Test 'make test TEST_VERBOSE=1'
100 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
101 $test_out = `$make_test_verbose`;
102 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
103 like( $test_out, qr/All tests successful/, '  successful' );
104 is( $?, 0 );
105
106 my $kill_err = $^O eq 'MSWin32' ? '2>&1' : ''; # avoid nmake spew
107 my $dist_test_out = `$make disttest $kill_err`;
108 is( $?, 0, 'disttest' ) || diag($dist_test_out);
109
110
111 # Make sure init_dirscan doesn't go into the distdir
112 @mpl_out = `$perl Makefile.PL "PREFIX=dummy-install"`;
113
114 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
115   diag(@mpl_out);
116
117 ok( 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.
124 open(SAVERR, ">&STDERR") or die $!;
125 open(STDERR, ">".File::Spec->devnull) or die $!;
126
127 my $realclean_out = `$make realclean`;
128 is( $?, 0, 'realclean' ) || diag($realclean_out);
129
130 open(STDERR, ">&SAVERR") or die $!;
131 close SAVERR;