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