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