9ec4f4ce28cd1eda57218d8162ddfeafb1c6e4fd
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / recurs.t
1 #!/usr/bin/perl -w
2
3 # This tests MakeMaker against recursive builds
4
5 BEGIN {
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
15 use strict;
16 use Config;
17
18 use Test::More tests => 25;
19 use MakeMaker::Test::Utils;
20 use MakeMaker::Test::Setup::Recurs;
21
22 # 'make disttest' sets a bunch of environment variables which interfere
23 # with our testing.
24 delete @ENV{qw(PREFIX LIB MAKEFLAGS)};
25
26 my $perl = which_perl();
27 my $Is_VMS = $^O eq 'VMS';
28
29 chdir('t');
30
31 perl_lib;
32
33 my $Touch_Time = calibrate_mtime();
34
35 $| = 1;
36
37 ok( setup_recurs(), 'setup' );
38 END { 
39     ok( chdir File::Spec->updir );
40     ok( teardown_recurs(), 'teardown' );
41 }
42
43 ok( chdir('Recurs'), q{chdir'd to Recurs} ) ||
44     diag("chdir failed: $!");
45
46
47 # Check recursive Makefile building.
48 my @mpl_out = run(qq{$perl Makefile.PL});
49
50 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
51   diag(@mpl_out);
52
53 my $makefile = makefile_name();
54
55 ok( -e $makefile, 'Makefile written' );
56 ok( -e File::Spec->catfile('prj2',$makefile), 'sub Makefile written' );
57
58 my $make = make_run();
59
60 run("$make");
61 is( $?, 0, 'recursive make exited normally' );
62
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: $!");
68
69
70 # Check NORECURS
71 @mpl_out = run(qq{$perl Makefile.PL "NORECURS=1"});
72
73 cmp_ok( $?, '==', 0, 'Makefile.PL NORECURS=1 exited with zero' ) ||
74   diag(@mpl_out);
75
76 $makefile = makefile_name();
77
78 ok( -e $makefile, 'Makefile written' );
79 ok( !-e File::Spec->catfile('prj2',$makefile), 'sub Makefile not written' );
80
81 $make = make_run();
82
83 run("$make");
84 is( $?, 0, 'recursive make exited normally' );
85
86
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: $!");
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
98 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
99   diag(@mpl_out);
100
101 $makefile = makefile_name();
102 my $submakefile = File::Spec->catfile('prj2',$makefile);
103
104 ok( -e $makefile,    'Makefile written' );
105 ok( -e $submakefile, 'sub Makefile written' );
106
107 my $inst_script = File::Spec->catdir(File::Spec->updir, 'cgi');
108 ok( 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 }
113 close MAKEFILE;