7542bd33ed37d8320e39dcfae124a306c4545049
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / hints.t
1 BEGIN {
2     if( $ENV{PERL_CORE} ) {
3         chdir 't';
4         @INC = ('../lib', 'lib/');
5     }
6     else {
7         unshift @INC, 't/lib/';
8     }
9 }
10 $ENV{PERL_CORE} ? chdir '../lib/ExtUtils/t' : chdir 't';
11
12 use Test::More tests => 3;
13
14 mkdir 'hints';
15 my $hint_file = "hints/$^O.pl";
16 open(HINT, ">$hint_file") || die "Can't write dummy hints file $hint_file: $!";
17 print HINT <<'CLOO';
18 $self->{CCFLAGS} = 'basset hounds got long ears';
19 CLOO
20 close HINT;
21
22 use TieOut;
23 use ExtUtils::MakeMaker;
24
25 my $out = tie *STDERR, 'TieOut';
26 my $mm = bless {}, 'ExtUtils::MakeMaker';
27 $mm->check_hints;
28 is( $mm->{CCFLAGS}, 'basset hounds got long ears' );
29 is( $out->read, "Processing hints file $hint_file\n" );
30
31 open(HINT, ">$hint_file") || die "Can't write dummy hints file $hint_file: $!";
32 print HINT <<'CLOO';
33 die "Argh!\n";
34 CLOO
35 close HINT;
36
37 $mm->check_hints;
38 is( $out->read, <<OUT, 'hint files produce errors' );
39 Processing hints file $hint_file
40 Argh!
41 OUT
42
43 END {
44     use File::Path;
45     rmtree ['hints'];
46 }