Here's tests for ExtUtils::MM_Cygwin.  They're skipped on all platforms where
$^O does not match /cygwin/i.  The tests out to pass just about everywhere
anyway.

It would be good for someone with Cygwin to test them, though.

-- c

--- ~MANIFEST   Sun Nov 25 19:50:46 2001
+++ MANIFEST    Sun Nov 25 19:51:06 2001
@@ -930,6 +930,7 @@
 lib/ExtUtils/Mkbootstrap.t     See if ExtUtils::Mkbootstrap works
 lib/ExtUtils/Mksymlists.pm     Writes a linker options file for extensions
 lib/ExtUtils/MM_Cygwin.pm      MakeMaker methods for Cygwin
+lib/ExtUtils/MM_Cygwin.pm      See if ExtUtils::MM_Cygwin works
 lib/ExtUtils/MM_NW5.pm         MakeMaker methods for NetWare
 lib/ExtUtils/MM_OS2.pm         MakeMaker methods for OS/2
 lib/ExtUtils/MM_Unix.pm                MakeMaker base class for Unix
--- /dev/null   Thu Aug 30 03:54:37 2001
+++ lib/ExtUtils/MM_Cygwin.t    Sun Nov 25 20:03:22 2001
@@ -0,0 +1,120 @@
+#!./perl
+
+BEGIN {
+       chdir 't' if -d 't';
+       @INC = '../lib';
+}
+
+use Test::More;
+
+BEGIN {
+       if ($^O =~ /cygwin/i) {
+               plan tests => 17;
+               $ENV{'ExtUtils/MM_Unix.pm'} = 1;
+       } else {
+               plan skip_all => 'Test irrelevant outside of Cygwin';
+       }
+}
+
+use Config;
+use File::Spec;
+
+use_ok( 'ExtUtils::MM_Cygwin' );
+
+# test canonpath
+my $path = File::Spec->canonpath('/a/../../c');
+is( ExtUtils::MM_Cygwin->canonpath('/a/../../c'), $path,
+       'canonpath() should delegate to File::Spec' );
+
+# test cflags, with the fake package below
+my $args = ExtUtils::MM_Unix->new({
+       CFLAGS  => 'fakeflags',
+       CCFLAGS => '',
+});
+
+# with CFLAGS set, it should be returned
+is( ExtUtils::MM_Cygwin::cflags($args), 'fakeflags',
+       'cflags() should return CFLAGS member data, if set' );
+
+delete $args->{CFLAGS};
+
+# respects the config setting, should ignore whitespace around equal sign
+my $ccflags = $Config{useshrplib} eq 'true' ? ' -DUSEIMPORTLIB' : '';
+ExtUtils::MM_Cygwin::cflags($args, <<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' );
+
+# test manifypods
+my $args = ExtUtils::MM_Unix->new({
+       NOECHO => 'noecho',
+       MAN3PODS => {},
+       MAN1PODS => {},
+});
+like( ExtUtils::MM_Cygwin::manifypods($args), qr/pure_all\n\tnoecho/,
+       'manifypods() should return without PODS values set' );
+
+$args->{MAN3PODS} = { foo => 1 };
+my $out = tie *STDOUT, 'FakeOut';
+my $res = ExtUtils::MM_Cygwin::manifypods($args);
+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' );
+
+$args->{PERL_SRC} = 'perlsrc';
+$args->{MAN1PODS} = { bar => 1 };
+$$out = '';
+$res = ExtUtils::MM_Cygwin::manifypods($args);
+is( $$out, '', '... should not warn if PERL_SRC provided' );
+like( $res, qr/bar \\\n\t1 \\\n\tfoo/, '... should join MAN1PODS and MAN3PODS');
+
+
+# test perl_archive
+my $libperl = $Config{libperl} || 'libperl.a';
+is( ExtUtils::MM_Cygwin::perl_archive(), "\$(PERL_INC)/$libperl",
+       'perl_archive() should respect libperl setting' );
+
+# test import of $Verbose and &neatvalue
+can_ok( 'ExtUtils::MM_Cygwin::neatvalue' );
+is( $ExtUtils::MM_Cygwin::Verbose, $ExtUtils::MakeMaker::Verbose, 
+       'ExtUtils::MM_Cygwin should import $Verbose from ExtUtils::MakeMaker' );
+
+package ExtUtils::MM_Unix;
+
+sub new {
+       bless($_[1], $_[0]);
+}
+
+sub cflags {
+       return $_[1];
+}
+
+sub catfile {
+       my $self = shift;
+       return join('/', @_);
+}
+
+sub perl_script { 
+       exists $_[0]->{PERL_SRC};
+}
+
+package FakeOut;
+
+sub TIEHANDLE {
+       bless(\(my $scalar), $_[0]);
+}
+
+sub PRINT {
+       my $self = shift;
+       $$self .= shift;
+}

Reply via email to