Forgot from #14641.
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / MM_Cygwin.t
CommitLineData
39234879 1#!/usr/bin/perl
c9b71ffd 2
3BEGIN {
39234879 4 if( $ENV{PERL_CORE} ) {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 }
c9b71ffd 8}
39234879 9chdir 't';
c9b71ffd 10
11use Test::More;
12
13BEGIN {
14 if ($^O =~ /cygwin/i) {
15 plan tests => 17;
16 } else {
8881896e 17 plan skip_all => "This is not cygwin";
c9b71ffd 18 }
19}
20
21use Config;
22use File::Spec;
23
24# MM package faked up by messy MI entanglement
25@MM::ISA = qw( ExtUtils::MM_Unix ExtUtils::Liblist::Kid ExtUtils::MakeMaker );
26
27use_ok( 'ExtUtils::MM_Cygwin' );
28
29# test canonpath
30my $path = File::Spec->canonpath('/a/../../c');
31is( MM->canonpath('/a/../../c'), $path,
32 'canonpath() method should work just like the one in File::Spec' );
33
34# test cflags, with the fake package below
35my $args = bless({
36 CFLAGS => 'fakeflags',
37 CCFLAGS => '',
38}, MM);
39
40# with CFLAGS set, it should be returned
41is( $args->cflags(), 'fakeflags',
42 'cflags() should return CFLAGS member data, if set' );
43
44delete $args->{CFLAGS};
45
46# ExtUtils::MM_Cygwin::cflags() calls this, fake the output
47*ExtUtils::MM_Unix::cflags = sub { return $_[1] };
48
49# respects the config setting, should ignore whitespace around equal sign
50my $ccflags = $Config{useshrplib} eq 'true' ? ' -DUSEIMPORTLIB' : '';
51$args->cflags(<<FLAGS);
52OPTIMIZE = opt
53PERLTYPE =pt
54LARGE= lg
55SPLIT=split
56FLAGS
57
58like( $args->{CFLAGS}, qr/OPTIMIZE = opt/, '... should set OPTIMIZE' );
59like( $args->{CFLAGS}, qr/PERLTYPE = pt/, '... should set PERLTYPE' );
60like( $args->{CFLAGS}, qr/LARGE = lg/, '... should set LARGE' );
61like( $args->{CFLAGS}, qr/SPLIT = split/, '... should set SPLIT' );
62like( $args->{CFLAGS}, qr/CCFLAGS = $ccflags/, '... should set CCFLAGS' );
63
64# test manifypods
65$args = bless({
66 NOECHO => 'noecho',
67 MAN3PODS => {},
68 MAN1PODS => {},
69}, 'MM');
70like( $args->manifypods(), qr/pure_all\n\tnoecho/,
71 'manifypods() should return without PODS values set' );
72
73$args->{MAN3PODS} = { foo => 1 };
74my $out = tie *STDOUT, 'FakeOut';
374f0998 75{
76 local *MM::perl_script = sub { return };
77 my $res = $args->manifypods();
78 like( $$out, qr/could not locate your pod2man/,
c9b71ffd 79 '... should warn if pod2man cannot be located' );
374f0998 80 like( $res, qr/POD2MAN_EXE = -S pod2man/,
c9b71ffd 81 '... should use default pod2man target' );
374f0998 82 like( $res, qr/pure_all.+foo/, '... should add MAN3PODS targets' );
83}
c9b71ffd 84$args->{PERL_SRC} = File::Spec->updir;
85$args->{MAN1PODS} = { bar => 1 };
86$$out = '';
87$res = $args->manifypods();
88is( $$out, '', '... should not warn if PERL_SRC provided' );
89like( $res, qr/bar \\\n\t1 \\\n\tfoo/, '... should join MAN1PODS and MAN3PODS');
90
91# test perl_archive
92my $libperl = $Config{libperl} || 'libperl.a';
b53432e4 93$libperl =~ s/.a/.dll.a/;
c9b71ffd 94is( $args->perl_archive(), "\$(PERL_INC)/$libperl",
95 'perl_archive() should respect libperl setting' );
96
97# test import of $Verbose and &neatvalue
98can_ok( 'ExtUtils::MM_Cygwin', 'neatvalue' );
99is( $ExtUtils::MM_Cygwin::Verbose, $ExtUtils::MakeMaker::Verbose,
100 'ExtUtils::MM_Cygwin should import $Verbose from ExtUtils::MakeMaker' );
101
102package FakeOut;
103
104sub TIEHANDLE {
105 bless(\(my $scalar), $_[0]);
106}
107
108sub PRINT {
109 my $self = shift;
110 $$self .= shift;
111}