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