This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
MakeMaker core sync 5.54_01 -> 5.55_02
[perl5.git] / lib / ExtUtils / t / MM_Cygwin.t
CommitLineData
39234879 1#!/usr/bin/perl
c9b71ffd 2
3BEGIN {
39234879
MS
4 if( $ENV{PERL_CORE} ) {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 }
f6d6199c
MS
8 else {
9 unshift @INC, 't/lib';
10 }
c9b71ffd 11}
39234879 12chdir 't';
c9b71ffd 13
14use Test::More;
15
16BEGIN {
17 if ($^O =~ /cygwin/i) {
f6d6199c 18 plan tests => 15;
c9b71ffd 19 } else {
8881896e 20 plan skip_all => "This is not cygwin";
c9b71ffd 21 }
22}
23
24use Config;
25use File::Spec;
e0678a30 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
f6d6199c
MS
48{
49 no warnings 'redefine';
50 sub ExtUtils::MM_Unix::cflags { return $_[1] };
51}
c9b71ffd 52
53# respects the config setting, should ignore whitespace around equal sign
54my $ccflags = $Config{useshrplib} eq 'true' ? ' -DUSEIMPORTLIB' : '';
e0678a30
MS
55{
56 local $args->{NEEDS_LINKING} = 1;
57 $args->cflags(<<FLAGS);
c9b71ffd 58OPTIMIZE = opt
59PERLTYPE =pt
60LARGE= lg
61SPLIT=split
62FLAGS
e0678a30 63}
c9b71ffd 64
65like( $args->{CFLAGS}, qr/OPTIMIZE = opt/, '... should set OPTIMIZE' );
66like( $args->{CFLAGS}, qr/PERLTYPE = pt/, '... should set PERLTYPE' );
67like( $args->{CFLAGS}, qr/LARGE = lg/, '... should set LARGE' );
68like( $args->{CFLAGS}, qr/SPLIT = split/, '... should set SPLIT' );
69like( $args->{CFLAGS}, qr/CCFLAGS = $ccflags/, '... should set CCFLAGS' );
70
71# test manifypods
72$args = bless({
73 NOECHO => 'noecho',
74 MAN3PODS => {},
75 MAN1PODS => {},
f6d6199c 76 MAKEFILE => 'Makefile',
c9b71ffd 77}, 'MM');
78like( $args->manifypods(), qr/pure_all\n\tnoecho/,
79 'manifypods() should return without PODS values set' );
80
81$args->{MAN3PODS} = { foo => 1 };
82my $out = tie *STDOUT, 'FakeOut';
374f0998 83{
f6d6199c
MS
84 no warnings 'once';
85 local *MM::perl_script = sub { return };
86 my $res = $args->manifypods();
87 like( $$out, qr/could not locate your pod2man/,
88 '... should warn if pod2man cannot be located' );
89 like( $res, qr/POD2MAN_EXE = -S pod2man/,
90 '... should use default pod2man target' );
91 like( $res, qr/pure_all.+foo/, '... should add MAN3PODS targets' );
92}
93
94SKIP: {
95 skip "Only relevent in the core", 2 unless $ENV{PERL_CORE};
96 $args->{PERL_SRC} = File::Spec->updir;
97 $args->{MAN1PODS} = { bar => 1 };
98 $$out = '';
99 $res = $args->manifypods();
100 is( $$out, '', '... should not warn if PERL_SRC provided' );
101 like( $res, qr/bar \\\n\t1 \\\n\tfoo/,
102 '... should join MAN1PODS and MAN3PODS');
374f0998 103}
c9b71ffd 104
105# test perl_archive
106my $libperl = $Config{libperl} || 'libperl.a';
f6d6199c 107$libperl =~ s/\.a/.dll.a/;
c9b71ffd 108is( $args->perl_archive(), "\$(PERL_INC)/$libperl",
109 'perl_archive() should respect libperl setting' );
110
c9b71ffd 111
112package FakeOut;
113
114sub TIEHANDLE {
115 bless(\(my $scalar), $_[0]);
116}
117
118sub PRINT {
119 my $self = shift;
120 $$self .= shift;
121}