Time::HiRes: Do not create files in blib directories under core
[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
479d2113 14use strict;
c9b71ffd 15use Test::More;
16
17BEGIN {
18 if ($^O =~ /cygwin/i) {
6df87cfb 19 plan tests => 13;
c9b71ffd 20 } else {
6df87cfb 21 plan skip_all => "This is not cygwin";
c9b71ffd 22 }
23}
24
25use Config;
26use File::Spec;
6df87cfb 27use ExtUtils::MM;
c9b71ffd 28
29use_ok( 'ExtUtils::MM_Cygwin' );
30
31# test canonpath
32my $path = File::Spec->canonpath('/a/../../c');
33is( MM->canonpath('/a/../../c'), $path,
34 'canonpath() method should work just like the one in File::Spec' );
35
36# test cflags, with the fake package below
479d2113 37my $MM = bless({
c9b71ffd 38 CFLAGS => 'fakeflags',
39 CCFLAGS => '',
479d2113 40}, 'MM');
c9b71ffd 41
42# with CFLAGS set, it should be returned
479d2113 43is( $MM->cflags(), 'fakeflags',
c9b71ffd 44 'cflags() should return CFLAGS member data, if set' );
45
479d2113 46delete $MM->{CFLAGS};
c9b71ffd 47
48# ExtUtils::MM_Cygwin::cflags() calls this, fake the output
6df87cfb 49{
57b1a898 50 local $SIG{__WARN__} = sub {
57b1a898 51 warn @_ unless $_[0] =~ /^Subroutine .* redefined/;
52 };
479d2113 53 *ExtUtils::MM_Unix::cflags = sub { return $_[1] };
6df87cfb 54}
c9b71ffd 55
56# respects the config setting, should ignore whitespace around equal sign
57my $ccflags = $Config{useshrplib} eq 'true' ? ' -DUSEIMPORTLIB' : '';
6df87cfb 58{
479d2113 59 local $MM->{NEEDS_LINKING} = 1;
60 $MM->cflags(<<FLAGS);
c9b71ffd 61OPTIMIZE = opt
62PERLTYPE =pt
c9b71ffd 63FLAGS
6df87cfb 64}
c9b71ffd 65
479d2113 66like( $MM->{CFLAGS}, qr/OPTIMIZE = opt/, '... should set OPTIMIZE' );
67like( $MM->{CFLAGS}, qr/PERLTYPE = pt/, '... should set PERLTYPE' );
68like( $MM->{CFLAGS}, qr/CCFLAGS = $ccflags/, '... should set CCFLAGS' );
c9b71ffd 69
70# test manifypods
479d2113 71$MM = bless({
c9b71ffd 72 NOECHO => 'noecho',
73 MAN3PODS => {},
74 MAN1PODS => {},
6df87cfb 75 MAKEFILE => 'Makefile',
c9b71ffd 76}, 'MM');
479d2113 77unlike( $MM->manifypods(), qr/foo/,
c9b71ffd 78 'manifypods() should return without PODS values set' );
79
479d2113 80$MM->{MAN3PODS} = { foo => 'foo.1' };
81my $res = $MM->manifypods();
82like( $res, qr/pure_all.*foo.*foo.1/s, '... should add MAN3PODS targets' );
83
6df87cfb 84
85SKIP: {
86 skip "Only relevent in the core", 2 unless $ENV{PERL_CORE};
479d2113 87 $MM->{PERL_SRC} = File::Spec->updir;
88 $MM->{MAN1PODS} = { bar => 1 };
89 my $out = tie *STDOUT, 'FakeOut';
90 $res = $MM->manifypods();
6df87cfb 91 is( $$out, '', '... should not warn if PERL_SRC provided' );
92 like( $res, qr/bar \\\n\t1 \\\n\tfoo/,
93 '... should join MAN1PODS and MAN3PODS');
94}
c9b71ffd 95
479d2113 96
97# init_linker
98{
99 my $libperl = $Config{libperl} || 'libperl.a';
100 $libperl =~ s/\.a/.dll.a/ if $] >= 5.007;
101 $libperl = "\$(PERL_INC)/$libperl";
102
103 my $export = '';
104 my $after = '';
105 $MM->init_linker;
106
107 is( $MM->{PERL_ARCHIVE}, $libperl, 'PERL_ARCHIVE' );
108 is( $MM->{PERL_ARCHIVE_AFTER}, $after, 'PERL_ARCHIVE_AFTER' );
109 is( $MM->{EXPORT_LIST}, $export, 'EXPORT_LIST' );
110}
111
c9b71ffd 112
c9b71ffd 113
114package FakeOut;
115
116sub TIEHANDLE {
117 bless(\(my $scalar), $_[0]);
118}
119
120sub PRINT {
121 my $self = shift;
122 $$self .= shift;
123}