3 # This tests MakeMaker against recursive builds
6 if( $ENV{PERL_CORE} ) {
8 @INC = ('../lib', 'lib');
11 unshift @INC, 't/lib';
18 use Test::More tests => 25;
19 use MakeMaker::Test::Utils;
20 use MakeMaker::Test::Setup::Recurs;
22 # 'make disttest' sets a bunch of environment variables which interfere
24 delete @ENV{qw(PREFIX LIB MAKEFLAGS)};
26 my $perl = which_perl();
27 my $Is_VMS = $^O eq 'VMS';
33 my $Touch_Time = calibrate_mtime();
37 ok( setup_recurs(), 'setup' );
39 ok( chdir File::Spec->updir );
40 ok( teardown_recurs(), 'teardown' );
43 ok( chdir('Recurs'), q{chdir'd to Recurs} ) ||
44 diag("chdir failed: $!");
47 # Check recursive Makefile building.
48 my @mpl_out = run(qq{$perl Makefile.PL});
50 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
53 my $makefile = makefile_name();
55 ok( -e $makefile, 'Makefile written' );
56 ok( -e File::Spec->catfile('prj2',$makefile), 'sub Makefile written' );
58 my $make = make_run();
60 my $make_out = run("$make");
61 is( $?, 0, 'recursive make exited normally' ) || diag $make_out;
63 ok( chdir File::Spec->updir );
64 ok( teardown_recurs(), 'cleaning out recurs' );
65 ok( setup_recurs(), ' setting up fresh copy' );
66 ok( chdir('Recurs'), q{chdir'd to Recurs} ) ||
67 diag("chdir failed: $!");
71 @mpl_out = run(qq{$perl Makefile.PL "NORECURS=1"});
73 cmp_ok( $?, '==', 0, 'Makefile.PL NORECURS=1 exited with zero' ) ||
76 $makefile = makefile_name();
78 ok( -e $makefile, 'Makefile written' );
79 ok( !-e File::Spec->catfile('prj2',$makefile), 'sub Makefile not written' );
84 is( $?, 0, 'recursive make exited normally' );
87 ok( chdir File::Spec->updir );
88 ok( teardown_recurs(), 'cleaning out recurs' );
89 ok( setup_recurs(), ' setting up fresh copy' );
90 ok( chdir('Recurs'), q{chdir'd to Recurs} ) ||
91 diag("chdir failed: $!");
94 # Check that arguments aren't stomped when they have .. prepended
96 @mpl_out = run(qq{$perl Makefile.PL "INST_SCRIPT=cgi"});
98 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
101 $makefile = makefile_name();
102 my $submakefile = File::Spec->catfile('prj2',$makefile);
104 ok( -e $makefile, 'Makefile written' );
105 ok( -e $submakefile, 'sub Makefile written' );
107 my $inst_script = File::Spec->catdir(File::Spec->updir, 'cgi');
108 ok( open(MAKEFILE, $submakefile) ) || diag("Can't open $submakefile: $!");
110 like( <MAKEFILE>, qr/^\s*INST_SCRIPT\s*=\s*\Q$inst_script\E/m,
111 'prepend .. not stomping WriteMakefile args' )