}
chdir 't';
+use strict;
use Test::More;
BEGIN {
if ($^O =~ /cygwin/i) {
- plan tests => 15;
+ plan tests => 14;
} else {
plan skip_all => "This is not cygwin";
}
use Config;
use File::Spec;
use ExtUtils::MM;
+use Config;
use_ok( 'ExtUtils::MM_Cygwin' );
'canonpath() method should work just like the one in File::Spec' );
# test cflags, with the fake package below
-my $args = bless({
+my $MM = bless({
CFLAGS => 'fakeflags',
CCFLAGS => '',
-}, MM);
+}, 'MM');
# with CFLAGS set, it should be returned
-is( $args->cflags(), 'fakeflags',
+is( $MM->cflags(), 'fakeflags',
'cflags() should return CFLAGS member data, if set' );
-delete $args->{CFLAGS};
+delete $MM->{CFLAGS};
# ExtUtils::MM_Cygwin::cflags() calls this, fake the output
{
- no warnings 'redefine';
- sub ExtUtils::MM_Unix::cflags { return $_[1] };
+ local $SIG{__WARN__} = sub {
+ warn @_ unless $_[0] =~ /^Subroutine .* redefined/;
+ };
+ *ExtUtils::MM_Unix::cflags = sub { return $_[1] };
}
# respects the config setting, should ignore whitespace around equal sign
my $ccflags = $Config{useshrplib} eq 'true' ? ' -DUSEIMPORTLIB' : '';
{
- local $args->{NEEDS_LINKING} = 1;
- $args->cflags(<<FLAGS);
+ local $MM->{NEEDS_LINKING} = 1;
+ $MM->cflags(<<FLAGS);
OPTIMIZE = opt
PERLTYPE =pt
-LARGE= lg
-SPLIT=split
FLAGS
}
-like( $args->{CFLAGS}, qr/OPTIMIZE = opt/, '... should set OPTIMIZE' );
-like( $args->{CFLAGS}, qr/PERLTYPE = pt/, '... should set PERLTYPE' );
-like( $args->{CFLAGS}, qr/LARGE = lg/, '... should set LARGE' );
-like( $args->{CFLAGS}, qr/SPLIT = split/, '... should set SPLIT' );
-like( $args->{CFLAGS}, qr/CCFLAGS = $ccflags/, '... should set CCFLAGS' );
+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' );
# test manifypods
-$args = bless({
+$MM = bless({
NOECHO => 'noecho',
MAN3PODS => {},
MAN1PODS => {},
MAKEFILE => 'Makefile',
}, 'MM');
-like( $args->manifypods(), qr/pure_all\n\tnoecho/,
+unlike( $MM->manifypods(), qr/foo/,
'manifypods() should return without PODS values set' );
-$args->{MAN3PODS} = { foo => 1 };
-my $out = tie *STDOUT, 'FakeOut';
+$MM->{MAN3PODS} = { foo => 'foo.1' };
+my $res = $MM->manifypods();
+like( $res, qr/pure_all.*foo.*foo.1/s, '... should add MAN3PODS targets' );
+
+
+# init_linker
{
- no warnings 'once';
- local *MM::perl_script = sub { return };
- my $res = $args->manifypods();
- like( $$out, qr/could not locate your pod2man/,
- '... should warn if pod2man cannot be located' );
- like( $res, qr/POD2MAN_EXE = -S pod2man/,
- '... should use default pod2man target' );
- like( $res, qr/pure_all.+foo/, '... 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' );
}
+# Tests for correct handling of maybe_command in /cygdrive/*
+# and c:/*. $ENV{COMSPEC}, if it exists, should always be executable.
SKIP: {
- skip "Only relevent in the core", 2 unless $ENV{PERL_CORE};
- $args->{PERL_SRC} = File::Spec->updir;
- $args->{MAN1PODS} = { bar => 1 };
- $$out = '';
- $res = $args->manifypods();
- is( $$out, '', '... should not warn if PERL_SRC provided' );
- like( $res, qr/bar \\\n\t1 \\\n\tfoo/,
- '... should join MAN1PODS and MAN3PODS');
+ 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"});
+ }
+
+ # 'C:/' should *never* be executable, it's a directory.
+ {
+ my $cdrive = Cygwin::win_to_posix_path("C:/");
+
+ ok(!MM->maybe_command($cdrive), qq{'$cdrive' should never be executable});
+ }
}
-# test perl_archive
-my $libperl = $Config{libperl} || 'libperl.a';
-$libperl =~ s/\.a/.dll.a/;
-is( $args->perl_archive(), "\$(PERL_INC)/$libperl",
- 'perl_archive() should respect libperl setting' );
+# Our copy of Perl (with a unix-path) should always be executable.
+ok(MM->maybe_command($Config{perlpath}), qq{'$Config{perlpath}' should be executable});
package FakeOut;