ExtUtils::MakeMaker 6.55_02
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / MM_Unix.t
CommitLineData
39234879 1#!/usr/bin/perl -w
c7a17d47 2
3BEGIN {
39234879 4 if( $ENV{PERL_CORE} ) {
64964e6d 5 chdir 't';
39234879 6 @INC = '../lib';
7 }
f6d6199c 8 else {
9 unshift @INC, 't/lib';
10 }
c7a17d47 11}
39234879 12chdir 't';
c7a17d47 13
87a750c3 14BEGIN {
15 use Test::More;
16
85c35b1b 17 if( $^O =~ /^VMS|os2|MacOS|MSWin32|cygwin|beos|netware$/i ) {
87a750c3 18 plan skip_all => 'Non-Unix platform';
19 }
20 else {
5bdf71cc 21 plan tests => 110;
87a750c3 22 }
23}
c7a17d47 24
25BEGIN { use_ok( 'ExtUtils::MM_Unix' ); }
26
27use strict;
28use File::Spec;
29
30my $class = 'ExtUtils::MM_Unix';
31
32# only one of the following can be true
33# test should be removed if MM_Unix ever stops handling other OS than Unix
a592ba15 34my $os = ($ExtUtils::MM_Unix::Is{OS2} || 0)
35 + ($ExtUtils::MM_Unix::Is{Win32} || 0)
36 + ($ExtUtils::MM_Unix::Is{Dos} || 0)
37 + ($ExtUtils::MM_Unix::Is{VMS} || 0);
2e65e370 38cmp_ok ( $os, '<=', 1, 'There can be only one (or none)');
c7a17d47 39
2e65e370 40is($ExtUtils::MM_Unix::VERSION, $ExtUtils::MakeMaker::VERSION, 'MM_Unix has a $VERSION');
c7a17d47 41
42# when the following calls like canonpath, catdir etc are replaced by
43# File::Spec calls, the test's become a bit pointless
44
2e65e370 45foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) ) {
46 is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_");
47}
c7a17d47 48
49is ($class->catdir('xx','xx'), File::Spec->catdir('xx','xx'),
50 'catdir(xx, xx) => xx/xx');
51is ($class->catfile('xx','xx','yy'), File::Spec->catfile('xx','xx','yy'),
52 'catfile(xx, xx) => xx/xx');
53
f2cc0c2f 54is ($class->file_name_is_absolute('Bombdadil'),
55 File::Spec->file_name_is_absolute('Bombdadil'),
56 'file_name_is_absolute()');
57
58is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()');
59
c7a17d47 60foreach (qw/updir curdir rootdir/)
61 {
62 is ($class->$_(), File::Spec->$_(), $_ );
63 }
64
65foreach ( qw /
66 c_o
67 clean
68 const_cccmd
69 const_config
70 const_loadlibs
71 constants
72 depend
c7a17d47 73 dist
74 dist_basics
75 dist_ci
76 dist_core
479d2113 77 distdir
c7a17d47 78 dist_test
79 dlsyms
80 dynamic
81 dynamic_bs
82 dynamic_lib
83 exescan
c7a17d47 84 extliblist
c7a17d47 85 find_perl
86 fixin
87 force
88 guess_name
c7a17d47 89 init_dirscan
90 init_main
91 init_others
92 install
93 installbin
c7a17d47 94 linkext
95 lsdir
96 macro
97 makeaperl
98 makefile
99 manifypods
c7a17d47 100 needs_linking
c7a17d47 101 pasthru
c7a17d47 102 perldepend
103 pm_to_blib
c7a17d47 104 ppd
105 prefixify
106 processPL
107 quote_paren
108 realclean
c7a17d47 109 static
110 static_lib
111 staticmake
112 subdir_x
113 subdirs
114 test
115 test_via_harness
116 test_via_script
117 tool_autosplit
118 tool_xsubpp
119 tools_other
120 top_targets
121 writedoc
122 xs_c
123 xs_cpp
124 xs_o
c7a17d47 125 / )
126 {
f6d6199c 127 can_ok($class, $_);
c7a17d47 128 }
129
f2cc0c2f 130###############################################################################
131# some more detailed tests for the methods above
132
133ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
134
135###############################################################################
136# has_link_code tests
137
5c161494 138my $t = bless { NAME => "Foo" }, $class;
f2cc0c2f 139$t->{HAS_LINK_CODE} = 1;
140is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
141
142$t->{HAS_LINK_CODE} = 0;
143is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
144
145delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
146is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
147
148delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
149is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
150
151delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
152is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
153
154delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
155is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
156
157###############################################################################
158# libscan
159
479d2113 160is ($t->libscan('foo/RCS/bar'), '', 'libscan on RCS');
161is ($t->libscan('CVS/bar/car'), '', 'libscan on CVS');
162is ($t->libscan('SCCS'), '', 'libscan on SCCS');
163is ($t->libscan('.svn/something'), '', 'libscan on Subversion');
ad2f23df 164is ($t->libscan('foo/b~r'), 'foo/b~r', 'libscan on file with ~');
165is ($t->libscan('foo/RCS.pm'), 'foo/RCS.pm', 'libscan on file with RCS');
479d2113 166
167is ($t->libscan('Fatty'), 'Fatty', 'libscan on something not a VC file' );
f2cc0c2f 168
169###############################################################################
170# maybe_command
171
a7d1454b 172open(FILE, ">command"); print FILE "foo"; close FILE;
3722f0dc 173SKIP: {
bf87a6a1 174 skip("no separate execute mode on VOS", 2) if $^O eq "vos";
175
176 ok !$t->maybe_command('command') ,"non executable file isn't a command";
3722f0dc 177
bf87a6a1 178 chmod 0755, "command";
179 ok ($t->maybe_command('command'), "executable file is a command");
180}
a7d1454b 181unlink "command";
f2cc0c2f 182
f2cc0c2f 183
184###############################################################################
185# perl_script (on unix any ordinary, readable file)
186
a7d1454b 187my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t'
188 : 'MM_Unix.t';
f2cc0c2f 189is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
190
191###############################################################################
5bdf71cc 192# PERM_RW and PERM_RWX
f2cc0c2f 193
479d2113 194$t->init_PERM;
5bdf71cc 195is ($t->{PERM_RW},'644', 'PERM_RW is 644');
196is ($t->{PERM_RWX},'755', 'PERM_RWX is 755');
197is ($t->{PERM_DIR},'755', 'PERM_DIR is 755');
198
f2cc0c2f 199
200###############################################################################
201# post_constants, postamble, post_initialize
202
2e65e370 203foreach (qw/ post_constants postamble post_initialize/) {
f2cc0c2f 204 is ($t->$_(),'', "$_() is an empty string");
2e65e370 205}
f2cc0c2f 206
207###############################################################################
208# replace_manpage_separator
209
210is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator');
211
212###############################################################################
f2cc0c2f 213
479d2113 214$t->init_linker;
60537fc0 215foreach (qw/ EXPORT_LIST PERL_ARCHIVE PERL_ARCHIVE_AFTER /)
479d2113 216{
217 ok( exists $t->{$_}, "$_ was defined" );
60537fc0 218 is( $t->{$_}, '', "$_ is empty on Unix");
479d2113 219}
f2cc0c2f 220
c7a17d47 221
5c161494 222{
223 $t->{CCFLAGS} = '-DMY_THING';
224 $t->{LIBPERL_A} = 'libperl.a';
225 $t->{LIB_EXT} = '.a';
226 local $t->{NEEDS_LINKING} = 1;
227 $t->cflags();
228
229 # Brief bug where CCFLAGS was being blown away
230 is( $t->{CCFLAGS}, '-DMY_THING', 'cflags retains CCFLAGS' );
231}
232