Commit | Line | Data |
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 | |
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; |
e0678a30 |
17 | use Test::More tests => 17; |
75e2e551 |
18 | use MakeMaker::Test::Utils; |
19 | use File::Spec; |
20 | use TieOut; |
21 | |
e0678a30 |
22 | my $perl = which_perl(); |
75e2e551 |
23 | |
24 | $ENV{PERL_CORE} ? chdir '../lib/ExtUtils/t' : chdir 't'; |
25 | |
26 | perl_lib; |
27 | |
e0678a30 |
28 | my $Touch_Time = calibrate_mtime(); |
29 | |
75e2e551 |
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. |
e0678a30 |
38 | mkdir 't' || die "Can't create test dir: $!"; |
75e2e551 |
39 | open(TEST, ">t/compile.t") or die "Can't open t/compile.t: $!"; |
e0678a30 |
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 |
75e2e551 |
46 | close TEST; |
47 | |
e0678a30 |
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' } |
75e2e551 |
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 | |
e0678a30 |
77 | # -M is flakey on VMS |
78 | my $mtime = (stat($makefile))[9]; |
79 | cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' ); |
75e2e551 |
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 $dist_test_out = `$make disttest`; |
107 | is( $?, 0, 'disttest' ) || diag($dist_test_out); |
108 | |
e0678a30 |
109 | |
110 | # Make sure init_dirscan doesn't go into the distdir |
111 | @mpl_out = `$perl Makefile.PL "PREFIX=dummy-install"`; |
112 | |
113 | cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || |
114 | diag(@mpl_out); |
115 | |
116 | ok( 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. |
123 | open(SAVERR, ">&STDERR") or die $!; |
124 | open(STDERR, ">".File::Spec->devnull) or die $!; |
125 | |
75e2e551 |
126 | my $realclean_out = `$make realclean`; |
127 | is( $?, 0, 'realclean' ) || diag($realclean_out); |
128 | |
e0678a30 |
129 | open(STDERR, ">&SAVERR") or die $!; |
130 | close SAVERR; |