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