Commit | Line | Data |
c9b71ffd |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib'; |
6 | } |
7 | |
8 | use Test::More; |
9 | |
10 | BEGIN { |
11 | if ($^O =~ /cygwin/i) { |
12 | plan tests => 17; |
13 | } else { |
8881896e |
14 | plan skip_all => "This is not cygwin"; |
c9b71ffd |
15 | } |
16 | } |
17 | |
18 | use Config; |
19 | use 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 | |
24 | use_ok( 'ExtUtils::MM_Cygwin' ); |
25 | |
26 | # test canonpath |
27 | my $path = File::Spec->canonpath('/a/../../c'); |
28 | is( 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 |
32 | my $args = bless({ |
33 | CFLAGS => 'fakeflags', |
34 | CCFLAGS => '', |
35 | }, MM); |
36 | |
37 | # with CFLAGS set, it should be returned |
38 | is( $args->cflags(), 'fakeflags', |
39 | 'cflags() should return CFLAGS member data, if set' ); |
40 | |
41 | delete $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 |
47 | my $ccflags = $Config{useshrplib} eq 'true' ? ' -DUSEIMPORTLIB' : ''; |
48 | $args->cflags(<<FLAGS); |
49 | OPTIMIZE = opt |
50 | PERLTYPE =pt |
51 | LARGE= lg |
52 | SPLIT=split |
53 | FLAGS |
54 | |
55 | like( $args->{CFLAGS}, qr/OPTIMIZE = opt/, '... should set OPTIMIZE' ); |
56 | like( $args->{CFLAGS}, qr/PERLTYPE = pt/, '... should set PERLTYPE' ); |
57 | like( $args->{CFLAGS}, qr/LARGE = lg/, '... should set LARGE' ); |
58 | like( $args->{CFLAGS}, qr/SPLIT = split/, '... should set SPLIT' ); |
59 | like( $args->{CFLAGS}, qr/CCFLAGS = $ccflags/, '... should set CCFLAGS' ); |
60 | |
61 | # test manifypods |
62 | $args = bless({ |
63 | NOECHO => 'noecho', |
64 | MAN3PODS => {}, |
65 | MAN1PODS => {}, |
66 | }, 'MM'); |
67 | like( $args->manifypods(), qr/pure_all\n\tnoecho/, |
68 | 'manifypods() should return without PODS values set' ); |
69 | |
70 | $args->{MAN3PODS} = { foo => 1 }; |
71 | my $out = tie *STDOUT, 'FakeOut'; |
374f0998 |
72 | { |
73 | local *MM::perl_script = sub { return }; |
74 | my $res = $args->manifypods(); |
75 | like( $$out, qr/could not locate your pod2man/, |
c9b71ffd |
76 | '... should warn if pod2man cannot be located' ); |
374f0998 |
77 | like( $res, qr/POD2MAN_EXE = -S pod2man/, |
c9b71ffd |
78 | '... should use default pod2man target' ); |
374f0998 |
79 | like( $res, qr/pure_all.+foo/, '... should add MAN3PODS targets' ); |
80 | } |
c9b71ffd |
81 | $args->{PERL_SRC} = File::Spec->updir; |
82 | $args->{MAN1PODS} = { bar => 1 }; |
83 | $$out = ''; |
84 | $res = $args->manifypods(); |
85 | is( $$out, '', '... should not warn if PERL_SRC provided' ); |
86 | like( $res, qr/bar \\\n\t1 \\\n\tfoo/, '... should join MAN1PODS and MAN3PODS'); |
87 | |
88 | # test perl_archive |
89 | my $libperl = $Config{libperl} || 'libperl.a'; |
90 | is( $args->perl_archive(), "\$(PERL_INC)/$libperl", |
91 | 'perl_archive() should respect libperl setting' ); |
92 | |
93 | # test import of $Verbose and &neatvalue |
94 | can_ok( 'ExtUtils::MM_Cygwin', 'neatvalue' ); |
95 | is( $ExtUtils::MM_Cygwin::Verbose, $ExtUtils::MakeMaker::Verbose, |
96 | 'ExtUtils::MM_Cygwin should import $Verbose from ExtUtils::MakeMaker' ); |
97 | |
98 | package FakeOut; |
99 | |
100 | sub TIEHANDLE { |
101 | bless(\(my $scalar), $_[0]); |
102 | } |
103 | |
104 | sub PRINT { |
105 | my $self = shift; |
106 | $$self .= shift; |
107 | } |