Commit | Line | Data |
---|---|---|
6df87cfb | 1 | #!/usr/bin/perl |
c9b71ffd | 2 | |
3 | BEGIN { | |
6df87cfb JH |
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 | 12 | chdir 't'; |
c9b71ffd | 13 | |
479d2113 | 14 | use strict; |
c9b71ffd | 15 | use Test::More; |
16 | ||
17 | BEGIN { | |
18 | if ($^O =~ /cygwin/i) { | |
dedf98bc | 19 | plan tests => 11; |
c9b71ffd | 20 | } else { |
6df87cfb | 21 | plan skip_all => "This is not cygwin"; |
c9b71ffd | 22 | } |
23 | } | |
24 | ||
25 | use Config; | |
26 | use File::Spec; | |
6df87cfb | 27 | use ExtUtils::MM; |
c9b71ffd | 28 | |
29 | use_ok( 'ExtUtils::MM_Cygwin' ); | |
30 | ||
31 | # test canonpath | |
32 | my $path = File::Spec->canonpath('/a/../../c'); | |
33 | is( 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 | 37 | my $MM = bless({ |
c9b71ffd | 38 | CFLAGS => 'fakeflags', |
39 | CCFLAGS => '', | |
479d2113 | 40 | }, 'MM'); |
c9b71ffd | 41 | |
42 | # with CFLAGS set, it should be returned | |
479d2113 | 43 | is( $MM->cflags(), 'fakeflags', |
c9b71ffd | 44 | 'cflags() should return CFLAGS member data, if set' ); |
45 | ||
479d2113 | 46 | delete $MM->{CFLAGS}; |
c9b71ffd | 47 | |
48 | # ExtUtils::MM_Cygwin::cflags() calls this, fake the output | |
6df87cfb | 49 | { |
57b1a898 | 50 | local $SIG{__WARN__} = sub { |
57b1a898 MS |
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 | |
57 | my $ccflags = $Config{useshrplib} eq 'true' ? ' -DUSEIMPORTLIB' : ''; | |
6df87cfb | 58 | { |
479d2113 MS |
59 | local $MM->{NEEDS_LINKING} = 1; |
60 | $MM->cflags(<<FLAGS); | |
c9b71ffd | 61 | OPTIMIZE = opt |
62 | PERLTYPE =pt | |
c9b71ffd | 63 | FLAGS |
6df87cfb | 64 | } |
c9b71ffd | 65 | |
479d2113 MS |
66 | like( $MM->{CFLAGS}, qr/OPTIMIZE = opt/, '... should set OPTIMIZE' ); |
67 | like( $MM->{CFLAGS}, qr/PERLTYPE = pt/, '... should set PERLTYPE' ); | |
68 | like( $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 | 77 | unlike( $MM->manifypods(), qr/foo/, |
c9b71ffd | 78 | 'manifypods() should return without PODS values set' ); |
79 | ||
479d2113 MS |
80 | $MM->{MAN3PODS} = { foo => 'foo.1' }; |
81 | my $res = $MM->manifypods(); | |
82 | like( $res, qr/pure_all.*foo.*foo.1/s, '... should add MAN3PODS targets' ); | |
83 | ||
6df87cfb | 84 | |
479d2113 MS |
85 | # init_linker |
86 | { | |
87 | my $libperl = $Config{libperl} || 'libperl.a'; | |
88 | $libperl =~ s/\.a/.dll.a/ if $] >= 5.007; | |
89 | $libperl = "\$(PERL_INC)/$libperl"; | |
90 | ||
91 | my $export = ''; | |
92 | my $after = ''; | |
93 | $MM->init_linker; | |
94 | ||
95 | is( $MM->{PERL_ARCHIVE}, $libperl, 'PERL_ARCHIVE' ); | |
96 | is( $MM->{PERL_ARCHIVE_AFTER}, $after, 'PERL_ARCHIVE_AFTER' ); | |
97 | is( $MM->{EXPORT_LIST}, $export, 'EXPORT_LIST' ); | |
98 | } | |
99 | ||
c9b71ffd | 100 | |
c9b71ffd | 101 | |
102 | package FakeOut; | |
103 | ||
104 | sub TIEHANDLE { | |
105 | bless(\(my $scalar), $_[0]); | |
106 | } | |
107 | ||
108 | sub PRINT { | |
109 | my $self = shift; | |
110 | $$self .= shift; | |
111 | } |