xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/ExtUtils/t/hints.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/usr/bin/perl -w
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate    if( $ENV{PERL_CORE} ) {
5*0Sstevel@tonic-gate        chdir 't';
6*0Sstevel@tonic-gate        @INC = ('../lib', 'lib/');
7*0Sstevel@tonic-gate    }
8*0Sstevel@tonic-gate    else {
9*0Sstevel@tonic-gate        unshift @INC, 't/lib/';
10*0Sstevel@tonic-gate    }
11*0Sstevel@tonic-gate}
12*0Sstevel@tonic-gatechdir 't';
13*0Sstevel@tonic-gate
14*0Sstevel@tonic-gateuse File::Spec;
15*0Sstevel@tonic-gate
16*0Sstevel@tonic-gateuse Test::More tests => 3;
17*0Sstevel@tonic-gate
18*0Sstevel@tonic-gate# Having the CWD in @INC masked a bug in finding hint files
19*0Sstevel@tonic-gatemy $curdir = File::Spec->curdir;
20*0Sstevel@tonic-gate@INC = grep { $_ ne $curdir && $_ ne '.' } @INC;
21*0Sstevel@tonic-gate
22*0Sstevel@tonic-gatemkdir('hints', 0777);
23*0Sstevel@tonic-gatemy $hint_file = File::Spec->catfile('hints', "$^O.pl");
24*0Sstevel@tonic-gateopen(HINT, ">$hint_file") || die "Can't write dummy hints file $hint_file: $!";
25*0Sstevel@tonic-gateprint HINT <<'CLOO';
26*0Sstevel@tonic-gate$self->{CCFLAGS} = 'basset hounds got long ears';
27*0Sstevel@tonic-gateCLOO
28*0Sstevel@tonic-gateclose HINT;
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gateuse TieOut;
31*0Sstevel@tonic-gateuse ExtUtils::MakeMaker;
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gatemy $out = tie *STDERR, 'TieOut';
34*0Sstevel@tonic-gatemy $mm = bless {}, 'ExtUtils::MakeMaker';
35*0Sstevel@tonic-gate$mm->check_hints;
36*0Sstevel@tonic-gateis( $mm->{CCFLAGS}, 'basset hounds got long ears' );
37*0Sstevel@tonic-gateis( $out->read, "Processing hints file $hint_file\n" );
38*0Sstevel@tonic-gate
39*0Sstevel@tonic-gateopen(HINT, ">$hint_file") || die "Can't write dummy hints file $hint_file: $!";
40*0Sstevel@tonic-gateprint HINT <<'CLOO';
41*0Sstevel@tonic-gatedie "Argh!\n";
42*0Sstevel@tonic-gateCLOO
43*0Sstevel@tonic-gateclose HINT;
44*0Sstevel@tonic-gate
45*0Sstevel@tonic-gate$mm->check_hints;
46*0Sstevel@tonic-gateis( $out->read, <<OUT, 'hint files produce errors' );
47*0Sstevel@tonic-gateProcessing hints file $hint_file
48*0Sstevel@tonic-gateArgh!
49*0Sstevel@tonic-gateOUT
50*0Sstevel@tonic-gate
51*0Sstevel@tonic-gateEND {
52*0Sstevel@tonic-gate    use File::Path;
53*0Sstevel@tonic-gate    rmtree ['hints'];
54*0Sstevel@tonic-gate}
55