MM & Encode fixes
[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 => 15;
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 $| = 1;
29
30 ok( chdir 'Big-Fat-Dummy', "chdir'd to Big-Fat-Dummy" ) ||
31   diag("chdir failed: $!");
32
33
34 # The perl core test suite will run any .t file in the MANIFEST.
35 # So we have to generate this on the fly.
36 mkdir 't';
37 open(TEST, ">t/compile.t") or die "Can't open t/compile.t: $!";
38 print TEST <DATA>;
39 close TEST;
40
41 END { unlink 't/compile.t' }
42
43 my @mpl_out = `$perl Makefile.PL PREFIX=dummy-install`;
44
45 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
46   diag(@mpl_out);
47
48 my $makefile = makefile_name();
49 ok( grep(/^Writing $makefile for Big::Fat::Dummy/, 
50          @mpl_out) == 1,
51                                            'Makefile.PL output looks right');
52
53 ok( grep(/^Current package is: main$/,
54          @mpl_out) == 1,
55                                            'Makefile.PL run in package main');
56
57 ok( -e $makefile,       'Makefile exists' );
58
59 # -M is flakey on VMS, flat out broken on Tru64 5.6.0
60 SKIP: {
61     skip "stat a/mtime broken on Tru64 5.6.0", 1 if $^O eq 'dec_osf' and
62                                                     $] >= 5.006;
63
64     my $mtime = (stat($makefile))[9];
65     cmp_ok( $^T, '<=', $mtime,  '  its been touched' );
66 }
67
68 END { unlink makefile_name(), makefile_backup() }
69
70 my $make = make_run();
71
72 {
73     # Supress 'make manifest' noise
74     local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
75     my $manifest_out = `$make manifest`;
76     ok( -e 'MANIFEST',      'make manifest created a MANIFEST' );
77     ok( -s 'MANIFEST',      '  its not empty' );
78 }
79
80 END { unlink 'MANIFEST'; }
81
82 my $test_out = `$make test`;
83 like( $test_out, qr/All tests successful/, 'make test' );
84 is( $?, 0 );
85
86 # Test 'make test TEST_VERBOSE=1'
87 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
88 $test_out = `$make_test_verbose`;
89 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
90 like( $test_out, qr/All tests successful/, '  successful' );
91 is( $?, 0 );
92
93 my $dist_test_out = `$make disttest`;
94 is( $?, 0, 'disttest' ) || diag($dist_test_out);
95
96 my $realclean_out = `$make realclean`;
97 is( $?, 0, 'realclean' ) || diag($realclean_out);
98
99 __DATA__
100 print "1..2\n";
101
102 print eval "use Big::Fat::Dummy; 1;" ? "ok 1\n" : "not ok 1\n";
103 print "ok 2 - TEST_VERBOSE\n";