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