#!/usr/bin/perl -w
my
$tmpdir
= tempdir(
DIR
=>
't'
,
CLEANUP
=> 1 );
use
Cwd;
my
$cwd
= getcwd; END {
chdir
$cwd
}
chdir
$tmpdir
;
my
$curdir
= File::Spec->curdir;
@INC
=
grep
{
$_
ne
$curdir
&&
$_
ne
'.'
}
@INC
;
mkdir
(
'hints'
, 0777);
(
my
$os
= $^O) =~ s/\./_/g;
my
$Hint_File
= File::Spec->catfile(
'hints'
,
"$os.pl"
);
my
$mm
=
bless
{},
'ExtUtils::MakeMaker'
;
{
open
my
$hint_fh
,
">"
,
$Hint_File
||
die
"Can't write dummy hints file $Hint_File: $!"
;
print
$hint_fh
<<'CLOO';
$self->{CCFLAGS} = 'basset hounds got long ears';
CLOO
}
{
my
$stderr
=
''
;
local
$SIG
{__WARN__} =
sub
{
$stderr
.=
join
''
,
@_
};
$mm
->check_hints;
is(
$mm
->{CCFLAGS},
'basset hounds got long ears'
);
is(
$stderr
,
""
);
}
{
open
my
$hint_fh
,
">"
,
$Hint_File
||
die
"Can't write dummy hints file $Hint_File: $!"
;
print
$hint_fh
<<'CLOO';
die "Argh!\n";
CLOO
}
{
my
$stderr
=
''
;
local
$SIG
{__WARN__} =
sub
{
$stderr
.=
join
''
,
@_
};
$mm
->check_hints;
is(
$stderr
,
<<OUT, 'hint files produce errors' );
Argh!
OUT
}
END {
rmtree [
'hints'
];
}