This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
ExtUtils::MakeMaker 5.95_01 -> 5.96_01
[perl5.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 my $root_dir = 't';
25
26 if( $^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 $ IF F$TRNLNM("PERL_CORE") .EQS. "" .AND. F$TYPE(PERL_CORE) .EQS. ""
34 $ THEN
35 $!  building CPAN version
36 $   BFD_TEST_ROOT = F$PARSE("[.t]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
37 $ ELSE
38 $!  we're in the core
39 $   BFD_TEST_ROOT = F$PARSE("SYS$DISK:[]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
40 $ ENDIF
41 $ DEFINE/JOB/NOLOG/TRANSLATION=CONCEALED BFD_TEST_ROOT 'BFD_TEST_ROOT'
42 COMMAND
43     close BFDTMP;
44
45     system '@bfdtesttmp.com';
46     END { 1 while unlink 'bfdtesttmp.com' }
47     $root_dir = 'BFD_TEST_ROOT:[000000]';
48 }
49
50 chdir $root_dir;
51
52
53 perl_lib;
54
55 my $Touch_Time = calibrate_mtime();
56
57 $| = 1;
58
59 ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
60   diag("chdir failed: $!");
61
62 my @mpl_out = `$perl Makefile.PL PREFIX=dummy-install`;
63
64 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
65   diag(@mpl_out);
66
67 my $makefile = makefile_name();
68 ok( grep(/^Writing $makefile for Big::Dummy/, 
69          @mpl_out) == 1,
70                                            'Makefile.PL output looks right');
71
72 ok( grep(/^Current package is: main$/,
73          @mpl_out) == 1,
74                                            'Makefile.PL run in package main');
75
76 ok( -e $makefile,       'Makefile exists' );
77
78 # -M is flakey on VMS
79 my $mtime = (stat($makefile))[9];
80 cmp_ok( $Touch_Time, '<=', $mtime,  '  its been touched' );
81
82 END { unlink makefile_name(), makefile_backup() }
83
84 my $make = make_run();
85
86 {
87     # Supress 'make manifest' noise
88     local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
89     my $manifest_out = `$make manifest`;
90     ok( -e 'MANIFEST',      'make manifest created a MANIFEST' );
91     ok( -s 'MANIFEST',      '  its not empty' );
92 }
93
94 END { unlink 'MANIFEST'; }
95
96 my $test_out = `$make test`;
97 like( $test_out, qr/All tests successful/, 'make test' );
98 is( $?, 0 );
99
100 # Test 'make test TEST_VERBOSE=1'
101 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
102 $test_out = `$make_test_verbose`;
103 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
104 like( $test_out, qr/All tests successful/, '  successful' );
105 is( $?, 0 );
106
107 my $dist_test_out = `$make disttest`;
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::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;