1# Test problems in Makefile.PL's and hint files.
2
3BEGIN {
4    unshift @INC, 't/lib';
5}
6chdir 't';
7
8use strict;
9use Test::More tests => 6;
10use ExtUtils::MM;
11use MakeMaker::Test::Setup::Problem;
12use TieOut;
13
14my $MM = bless { DIR => ['subdir'] }, 'MM';
15
16ok( setup_recurs(), 'setup' );
17END {
18    ok( chdir File::Spec->updir );
19    ok( teardown_recurs(), 'teardown' );
20}
21
22ok( chdir 'Problem-Module', "chdir'd to Problem-Module" ) ||
23  diag("chdir failed: $!");
24
25
26# Make sure when Makefile.PL's break, they issue a warning.
27# Also make sure Makefile.PL's in subdirs still have '.' in @INC.
28{
29    my $stdout = tie *STDOUT, 'TieOut' or die;
30
31    my $warning = '';
32    local $SIG{__WARN__} = sub { $warning = join '', @_ };
33    eval { $MM->eval_in_subdirs; };
34
35    is( $stdout->read, qq{\@INC has .\n}, 'cwd in @INC' );
36    like( $@,
37          qr{^ERROR from evaluation of .*subdir.*Makefile.PL: YYYAaaaakkk},
38          'Makefile.PL death in subdir warns' );
39
40    untie *STDOUT;
41}
42