#!/usr/bin/perl
BEGIN {
unshift
@INC
,
't/lib'
;
}
chdir
't'
;
BEGIN {
if
($^O =~ /cygwin/i) {
plan
tests
=> 14;
}
else
{
plan
skip_all
=>
"This is not cygwin"
;
}
}
use_ok(
'ExtUtils::MM_Cygwin'
);
my
$path
= File::Spec->canonpath(
'/a/../../c'
);
is( MM->canonpath(
'/a/../../c'
),
$path
,
'canonpath() method should work just like the one in File::Spec'
);
my
$MM
=
bless
({
CFLAGS
=>
'fakeflags'
,
CCFLAGS
=>
''
,
},
'MM'
);
is(
$MM
->cflags(),
'fakeflags'
,
'cflags() should return CFLAGS member data, if set'
);
delete
$MM
->{CFLAGS};
{
local
$SIG
{__WARN__} =
sub
{
warn
@_
unless
$_
[0] =~ /^Subroutine .* redefined/;
};
*ExtUtils::MM_Unix::cflags
=
sub
{
return
$_
[1] };
}
my
$ccflags
=
$Config
{useshrplib} eq
'true'
?
' -DUSEIMPORTLIB'
:
''
;
{
local
$MM
->{NEEDS_LINKING} = 1;
$MM
->cflags(
<<FLAGS);
OPTIMIZE = opt
PERLTYPE =pt
FLAGS
}
like(
$MM
->{CFLAGS},
qr/OPTIMIZE = opt/
,
'... should set OPTIMIZE'
);
like(
$MM
->{CFLAGS},
qr/PERLTYPE = pt/
,
'... should set PERLTYPE'
);
like(
$MM
->{CFLAGS},
qr/CCFLAGS = $ccflags/
,
'... should set CCFLAGS'
);
$MM
=
bless
({
NOECHO
=>
'noecho'
,
MAN3PODS
=> {},
MAN1PODS
=> {},
MAKEFILE
=>
'Makefile'
,
},
'MM'
);
unlike(
$MM
->manifypods(),
qr/foo/
,
'manifypods() should return without PODS values set'
);
$MM
->{MAN3PODS} = {
foo
=>
'foo.1'
};
my
$res
=
$MM
->manifypods();
like(
$res
,
qr/manifypods.*foo.*foo.1/
s,
'... should add MAN3PODS targets'
);
{
my
$libperl
=
$Config
{libperl} ||
'libperl.a'
;
$libperl
=~ s/\.a/.dll.a/
if
"$]"
>= 5.006002;
$libperl
=
"\$(PERL_INC)/$libperl"
;
my
$export
=
''
;
my
$after
=
''
;
$MM
->init_linker;
is(
$MM
->{PERL_ARCHIVE},
$libperl
,
'PERL_ARCHIVE'
);
is(
$MM
->{PERL_ARCHIVE_AFTER},
$after
,
'PERL_ARCHIVE_AFTER'
);
is(
$MM
->{EXPORT_LIST},
$export
,
'EXPORT_LIST'
);
}
SKIP: {
skip
"Needs Cygwin::win_to_posix_path()"
, 2
unless
defined
&Cygwin::win_to_posix_path
;
SKIP: {
my
$comspec
=
$ENV
{COMSPEC};
skip(
q[$ENV{COMSPEC} does not exist]
, 1)
unless
$comspec
;
$comspec
= Cygwin::win_to_posix_path(
$comspec
);
ok(MM->maybe_command(
$comspec
),
qq{'$comspec' should be executable"}
);
}
{
my
$cdrive
= Cygwin::win_to_posix_path(
"C:/"
);
ok(!MM->maybe_command(
$cdrive
),
qq{'$cdrive' should never be executable}
);
}
}
SKIP: {
skip
"The Perl may not be installed yet when in core"
, 1
if
$ENV
{PERL_CORE};
ok(MM->maybe_command(
$Config
{perlpath}),
qq{'$Config{perlpath}
' should be executable});
}
sub
TIEHANDLE {
bless
(\(
my
$scalar
),
$_
[0]);
}
sub
PRINT {
my
$self
=
shift
;
$$self
.=
shift
;
}