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