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