Upgrade to ExtUtils::MakeMaker 6.40.
[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 {
3a0105ce 21 plan tests => 109;
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
34my $os = ($ExtUtils::MM_Unix::Is_OS2 || 0)
c7a17d47 35 + ($ExtUtils::MM_Unix::Is_Win32 || 0)
36 + ($ExtUtils::MM_Unix::Is_Dos || 0)
37 + ($ExtUtils::MM_Unix::Is_VMS || 0);
38ok ( $os <= 1, 'There can be only one (or none)');
39
c8d65f10 40cmp_ok ($ExtUtils::MM_Unix::VERSION, '>=', '1.12606', 'Should be at least version 1.12606');
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
45foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) )
46 {
47 is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_");
48 }
49
50is ($class->catdir('xx','xx'), File::Spec->catdir('xx','xx'),
51 'catdir(xx, xx) => xx/xx');
52is ($class->catfile('xx','xx','yy'), File::Spec->catfile('xx','xx','yy'),
53 'catfile(xx, xx) => xx/xx');
54
f2cc0c2f 55is ($class->file_name_is_absolute('Bombdadil'),
56 File::Spec->file_name_is_absolute('Bombdadil'),
57 'file_name_is_absolute()');
58
59is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()');
60
c7a17d47 61foreach (qw/updir curdir rootdir/)
62 {
63 is ($class->$_(), File::Spec->$_(), $_ );
64 }
65
66foreach ( qw /
67 c_o
68 clean
69 const_cccmd
70 const_config
71 const_loadlibs
72 constants
73 depend
c7a17d47 74 dist
75 dist_basics
76 dist_ci
77 dist_core
479d2113 78 distdir
c7a17d47 79 dist_test
80 dlsyms
81 dynamic
82 dynamic_bs
83 dynamic_lib
84 exescan
c7a17d47 85 extliblist
c7a17d47 86 find_perl
87 fixin
88 force
89 guess_name
c7a17d47 90 init_dirscan
91 init_main
92 init_others
93 install
94 installbin
c7a17d47 95 linkext
96 lsdir
97 macro
98 makeaperl
99 makefile
100 manifypods
c7a17d47 101 needs_linking
c7a17d47 102 pasthru
c7a17d47 103 perldepend
104 pm_to_blib
c7a17d47 105 ppd
106 prefixify
107 processPL
108 quote_paren
109 realclean
c7a17d47 110 static
111 static_lib
112 staticmake
113 subdir_x
114 subdirs
115 test
116 test_via_harness
117 test_via_script
118 tool_autosplit
119 tool_xsubpp
120 tools_other
121 top_targets
122 writedoc
123 xs_c
124 xs_cpp
125 xs_o
c7a17d47 126 / )
127 {
f6d6199c 128 can_ok($class, $_);
c7a17d47 129 }
130
f2cc0c2f 131###############################################################################
132# some more detailed tests for the methods above
133
134ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
135
136###############################################################################
137# has_link_code tests
138
5c161494 139my $t = bless { NAME => "Foo" }, $class;
f2cc0c2f 140$t->{HAS_LINK_CODE} = 1;
141is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
142
143$t->{HAS_LINK_CODE} = 0;
144is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
145
146delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
147is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
148
149delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
150is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
151
152delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
153is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
154
155delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
156is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
157
158###############################################################################
159# libscan
160
479d2113 161is ($t->libscan('foo/RCS/bar'), '', 'libscan on RCS');
162is ($t->libscan('CVS/bar/car'), '', 'libscan on CVS');
163is ($t->libscan('SCCS'), '', 'libscan on SCCS');
164is ($t->libscan('.svn/something'), '', 'libscan on Subversion');
ad2f23df 165is ($t->libscan('foo/b~r'), 'foo/b~r', 'libscan on file with ~');
166is ($t->libscan('foo/RCS.pm'), 'foo/RCS.pm', 'libscan on file with RCS');
479d2113 167
168is ($t->libscan('Fatty'), 'Fatty', 'libscan on something not a VC file' );
f2cc0c2f 169
170###############################################################################
171# maybe_command
172
a7d1454b 173open(FILE, ">command"); print FILE "foo"; close FILE;
174ok (!$t->maybe_command('command') ,"non executable file isn't a command");
175chmod 0755, "command";
176ok ($t->maybe_command('command'), "executable file is a command");
177unlink "command";
f2cc0c2f 178
f2cc0c2f 179
180###############################################################################
181# perl_script (on unix any ordinary, readable file)
182
a7d1454b 183my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t'
184 : 'MM_Unix.t';
f2cc0c2f 185is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
186
187###############################################################################
188# perm_rw perm_rwx
189
479d2113 190$t->init_PERM;
f2cc0c2f 191is ($t->perm_rw(),'644', 'perm_rw() is 644');
192is ($t->perm_rwx(),'755', 'perm_rwx() is 755');
193
194###############################################################################
195# post_constants, postamble, post_initialize
196
197foreach (qw/ post_constants postamble post_initialize/)
198 {
199 is ($t->$_(),'', "$_() is an empty string");
200 }
201
202###############################################################################
203# replace_manpage_separator
204
205is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator');
206
207###############################################################################
f2cc0c2f 208
479d2113 209$t->init_linker;
60537fc0 210foreach (qw/ EXPORT_LIST PERL_ARCHIVE PERL_ARCHIVE_AFTER /)
479d2113 211{
212 ok( exists $t->{$_}, "$_ was defined" );
60537fc0 213 is( $t->{$_}, '', "$_ is empty on Unix");
479d2113 214}
f2cc0c2f 215
c7a17d47 216
5c161494 217{
218 $t->{CCFLAGS} = '-DMY_THING';
219 $t->{LIBPERL_A} = 'libperl.a';
220 $t->{LIB_EXT} = '.a';
221 local $t->{NEEDS_LINKING} = 1;
222 $t->cflags();
223
224 # Brief bug where CCFLAGS was being blown away
225 is( $t->{CCFLAGS}, '-DMY_THING', 'cflags retains CCFLAGS' );
226}
227