xref: /openbsd-src/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/problems.t (revision 256a93a44f36679bee503f12e49566c2183f6181)
1# Test problems in Makefile.PL's and hint files.
2
3BEGIN {
4    unshift @INC, 't/lib';
5}
6chdir 't';
7
8use strict;
9use warnings;
10use Test::More tests => 5;
11use ExtUtils::MM;
12use MakeMaker::Test::Utils;
13use File::Path;
14use TieOut;
15
16my $MM = bless { DIR => ['subdir'] }, 'MM';
17my $DIRNAME = 'Problem-Module';
18my %FILES = (
19    'Makefile.PL'   => <<'END',
20use ExtUtils::MakeMaker;
21WriteMakefile(NAME    => 'Problem::Module');
22END
23
24    'subdir/Makefile.PL'    => <<'END',
25printf "\@INC %s .\n", (grep { $_ eq '.' } @INC) ? "has" : "doesn't have";
26warn "I think I'm going to be sick\n";
27die "YYYAaaaakkk\n";
28END
29
30);
31
32hash2files($DIRNAME, \%FILES);
33END {
34    ok( chdir File::Spec->updir, 'chdir ..' );
35    ok( rmtree($DIRNAME), 'teardown' );
36}
37
38ok( chdir $DIRNAME, "chdir'd to Problem-Module" ) ||
39  diag("chdir failed: $!");
40
41
42# Make sure when Makefile.PL's break, they issue a warning.
43# Also make sure Makefile.PL's in subdirs still have '.' in @INC.
44{
45    my $stdout = tie *STDOUT, 'TieOut' or die;
46
47    my $warning = '';
48    local $SIG{__WARN__} = sub { $warning = join '', @_ };
49    eval { $MM->eval_in_subdirs; };
50
51    is( $stdout->read, qq{\@INC has .\n}, 'cwd in @INC' );
52    like( $@,
53          qr{^ERROR from evaluation of .*subdir.*Makefile.PL: YYYAaaaakkk},
54          'Makefile.PL death in subdir warns' );
55
56    untie *STDOUT;
57}
58