ExtUtils::MakeMaker 6.03 -> 6.06_05ish
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / hints.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4     if( $ENV{PERL_CORE} ) {
5         chdir 't';
6         @INC = ('../lib', 'lib/');
7     }
8     else {
9         unshift @INC, 't/lib/';
10     }
11 }
12 chdir 't';
13
14 use File::Spec;
15
16 use Test::More tests => 3;
17
18 # Having the CWD in @INC masked a bug in finding hint files
19 my $curdir = File::Spec->curdir;
20 @INC = grep { $_ ne $curdir && $_ ne '.' } @INC;
21
22 mkdir('hints', 0777);
23 my $hint_file = File::Spec->catfile('hints', "$^O.pl");
24 open(HINT, ">$hint_file") || die "Can't write dummy hints file $hint_file: $!";
25 print HINT <<'CLOO';
26 $self->{CCFLAGS} = 'basset hounds got long ears';
27 CLOO
28 close HINT;
29
30 use TieOut;
31 use ExtUtils::MakeMaker;
32
33 my $out = tie *STDERR, 'TieOut';
34 my $mm = bless {}, 'ExtUtils::MakeMaker';
35 $mm->check_hints;
36 is( $mm->{CCFLAGS}, 'basset hounds got long ears' );
37 is( $out->read, "Processing hints file $hint_file\n" );
38
39 open(HINT, ">$hint_file") || die "Can't write dummy hints file $hint_file: $!";
40 print HINT <<'CLOO';
41 die "Argh!\n";
42 CLOO
43 close HINT;
44
45 $mm->check_hints;
46 is( $out->read, <<OUT, 'hint files produce errors' );
47 Processing hints file $hint_file
48 Argh!
49 OUT
50
51 END {
52     use File::Path;
53     rmtree ['hints'];
54 }