This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
746a09a21940d52d4ba352d57dc5bc96d3a14f39
[perl5.git] / ext / ExtUtils-MakeMaker / t / recurs.t
1 #!/usr/bin/perl -w
2
3 # This tests MakeMaker against recursive builds
4
5 BEGIN {
6     unshift @INC, 't/lib';
7 }
8
9 use strict;
10 use Config;
11
12 use Test::More tests => 26;
13 use MakeMaker::Test::Utils;
14 use MakeMaker::Test::Setup::Recurs;
15
16 # 'make disttest' sets a bunch of environment variables which interfere
17 # with our testing.
18 delete @ENV{qw(PREFIX LIB MAKEFLAGS)};
19
20 my $perl = which_perl();
21 my $Is_VMS = $^O eq 'VMS';
22
23 chdir('t');
24
25 perl_lib;
26
27 my $Touch_Time = calibrate_mtime();
28
29 $| = 1;
30
31 ok( setup_recurs(), 'setup' );
32 END { 
33     ok( chdir File::Spec->updir );
34     ok( teardown_recurs(), 'teardown' );
35 }
36
37 ok( chdir('Recurs'), q{chdir'd to Recurs} ) ||
38     diag("chdir failed: $!");
39
40
41 # Check recursive Makefile building.
42 my @mpl_out = run(qq{$perl Makefile.PL});
43
44 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
45   diag(@mpl_out);
46
47 my $makefile = makefile_name();
48
49 ok( -e $makefile, 'Makefile written' );
50 ok( -e File::Spec->catfile('prj2',$makefile), 'sub Makefile written' );
51
52 my $make = make_run();
53
54 my $make_out = run("$make");
55 is( $?, 0, 'recursive make exited normally' ) || diag $make_out;
56
57 ok( chdir File::Spec->updir );
58 ok( teardown_recurs(), 'cleaning out recurs' );
59 ok( setup_recurs(),    '  setting up fresh copy' );
60 ok( chdir('Recurs'), q{chdir'd to Recurs} ) ||
61     diag("chdir failed: $!");
62
63
64 # Check NORECURS
65 @mpl_out = run(qq{$perl Makefile.PL "NORECURS=1"});
66
67 cmp_ok( $?, '==', 0, 'Makefile.PL NORECURS=1 exited with zero' ) ||
68   diag(@mpl_out);
69
70 $makefile = makefile_name();
71
72 ok( -e $makefile, 'Makefile written' );
73 ok( !-e File::Spec->catfile('prj2',$makefile), 'sub Makefile not written' );
74
75 $make = make_run();
76
77 run("$make");
78 is( $?, 0, 'recursive make exited normally' );
79
80
81 ok( chdir File::Spec->updir );
82 ok( teardown_recurs(), 'cleaning out recurs' );
83 ok( setup_recurs(),    '  setting up fresh copy' );
84 ok( chdir('Recurs'), q{chdir'd to Recurs} ) ||
85     diag("chdir failed: $!");
86
87
88 # Check that arguments aren't stomped when they have .. prepended
89 # [rt.perl.org 4345]
90 @mpl_out = run(qq{$perl Makefile.PL "INST_SCRIPT=cgi"});
91
92 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
93   diag(@mpl_out);
94
95 $makefile = makefile_name();
96 my $submakefile = File::Spec->catfile('prj2',$makefile);
97
98 ok( -e $makefile,    'Makefile written' );
99 ok( -e $submakefile, 'sub Makefile written' );
100
101 my $inst_script = File::Spec->catdir(File::Spec->updir, 'cgi');
102 ok( open(MAKEFILE, $submakefile) ) || diag("Can't open $submakefile: $!");
103 { local $/;  
104   like( <MAKEFILE>, qr/^\s*INST_SCRIPT\s*=\s*\Q$inst_script\E/m, 
105         'prepend .. not stomping WriteMakefile args' ) 
106 }
107 close MAKEFILE;
108
109
110 {
111     # Quiet "make test" failure noise
112     close *STDERR;
113
114     my $test_out = run("$make test");
115     isnt $?, 0, 'test failure in a subdir causes make to fail';
116 }