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