MM_Unix.pm : work around File::Find problem on VMS
[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} ) {
5 chdir 't' if -d 't';
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 {
45bc4d3a 21 plan tests => 112;
87a750c3 22 }
23}
c7a17d47 24
25BEGIN { use_ok( 'ExtUtils::MM_Unix' ); }
26
57b1a898 27use vars qw($VERSION);
f2cc0c2f 28$VERSION = '0.02';
c7a17d47 29use strict;
30use File::Spec;
31
32my $class = 'ExtUtils::MM_Unix';
33
34# only one of the following can be true
35# test should be removed if MM_Unix ever stops handling other OS than Unix
36my $os = ($ExtUtils::MM_Unix::Is_OS2 || 0)
37 + ($ExtUtils::MM_Unix::Is_Mac || 0)
38 + ($ExtUtils::MM_Unix::Is_Win32 || 0)
39 + ($ExtUtils::MM_Unix::Is_Dos || 0)
40 + ($ExtUtils::MM_Unix::Is_VMS || 0);
41ok ( $os <= 1, 'There can be only one (or none)');
42
f2cc0c2f 43cmp_ok ($ExtUtils::MM_Unix::VERSION, '>=', '1.12606', 'Should be at least version 1.12606');
c7a17d47 44
45# when the following calls like canonpath, catdir etc are replaced by
46# File::Spec calls, the test's become a bit pointless
47
48foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) )
49 {
50 is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_");
51 }
52
53is ($class->catdir('xx','xx'), File::Spec->catdir('xx','xx'),
54 'catdir(xx, xx) => xx/xx');
55is ($class->catfile('xx','xx','yy'), File::Spec->catfile('xx','xx','yy'),
56 'catfile(xx, xx) => xx/xx');
57
f2cc0c2f 58is ($class->file_name_is_absolute('Bombdadil'),
59 File::Spec->file_name_is_absolute('Bombdadil'),
60 'file_name_is_absolute()');
61
62is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()');
63
c7a17d47 64foreach (qw/updir curdir rootdir/)
65 {
66 is ($class->$_(), File::Spec->$_(), $_ );
67 }
68
69foreach ( qw /
70 c_o
71 clean
72 const_cccmd
73 const_config
74 const_loadlibs
75 constants
76 depend
77 dir_target
78 dist
79 dist_basics
80 dist_ci
81 dist_core
82 dist_dir
83 dist_test
84 dlsyms
85 dynamic
86 dynamic_bs
87 dynamic_lib
88 exescan
89 export_list
90 extliblist
c7a17d47 91 find_perl
92 fixin
93 force
94 guess_name
c7a17d47 95 init_dirscan
96 init_main
97 init_others
98 install
99 installbin
c7a17d47 100 linkext
101 lsdir
102 macro
103 makeaperl
104 makefile
105 manifypods
c7a17d47 106 maybe_command_in_dirs
107 needs_linking
c7a17d47 108 pasthru
c7a17d47 109 perldepend
110 pm_to_blib
c7a17d47 111 ppd
112 prefixify
113 processPL
114 quote_paren
115 realclean
c7a17d47 116 static
117 static_lib
118 staticmake
119 subdir_x
120 subdirs
121 test
122 test_via_harness
123 test_via_script
124 tool_autosplit
125 tool_xsubpp
126 tools_other
127 top_targets
128 writedoc
129 xs_c
130 xs_cpp
131 xs_o
132 xsubpp_version
133 / )
134 {
f6d6199c 135 can_ok($class, $_);
c7a17d47 136 }
137
f2cc0c2f 138###############################################################################
139# some more detailed tests for the methods above
140
141ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
142
143###############################################################################
144# has_link_code tests
145
5c161494 146my $t = bless { NAME => "Foo" }, $class;
f2cc0c2f 147$t->{HAS_LINK_CODE} = 1;
148is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
149
150$t->{HAS_LINK_CODE} = 0;
151is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
152
153delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
154is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
155
156delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
157is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
158
159delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
160is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
161
162delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
163is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
164
165###############################################################################
166# libscan
167
168is ($t->libscan('RCS'),'','libscan on RCS');
169is ($t->libscan('CVS'),'','libscan on CVS');
170is ($t->libscan('SCCS'),'','libscan on SCCS');
171is ($t->libscan('Fatty'),'Fatty','libscan on something not RCS, CVS or SCCS');
172
173###############################################################################
174# maybe_command
175
176is ($t->maybe_command('blargel'),undef,"'blargel' isn't a command");
177
178###############################################################################
179# nicetext (dummy method)
180
181is ($t->nicetext('LOTR'),'LOTR','nicetext');
182
183###############################################################################
184# parse_version
185
39234879 186my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t'
187 : 'MM_Unix.t';
f2cc0c2f 188
45bc4d3a 189is( $t->parse_version($self_name), '0.02', 'parse_version on ourself');
190
191my %versions = (
192 '$VERSION = 0.0' => 0.0,
193 '$VERSION = -1.0' => -1.0,
194 '$VERSION = undef' => 'undef',
195 '$wibble = 1.0' => 'undef',
196 );
197
198while( my($code, $expect) = each %versions ) {
199 open(FILE, ">VERSION.tmp") || die $!;
200 print FILE "$code\n";
201 close FILE;
202
203 is( $t->parse_version('VERSION.tmp'), $expect, $code );
204
205 unlink "VERSION.tmp";
206}
207
f2cc0c2f 208
209###############################################################################
210# perl_script (on unix any ordinary, readable file)
211
212is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
213
214###############################################################################
215# perm_rw perm_rwx
216
217is ($t->perm_rw(),'644', 'perm_rw() is 644');
218is ($t->perm_rwx(),'755', 'perm_rwx() is 755');
219
220###############################################################################
221# post_constants, postamble, post_initialize
222
223foreach (qw/ post_constants postamble post_initialize/)
224 {
225 is ($t->$_(),'', "$_() is an empty string");
226 }
227
228###############################################################################
229# replace_manpage_separator
230
231is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator');
232
233###############################################################################
234# export_list, perl_archive, perl_archive_after
235
236foreach (qw/ export_list perl_archive perl_archive_after/)
237 {
238 is ($t->$_(),'',"$_() is empty string on Unix");
239 }
240
c7a17d47 241
5c161494 242{
243 $t->{CCFLAGS} = '-DMY_THING';
244 $t->{LIBPERL_A} = 'libperl.a';
245 $t->{LIB_EXT} = '.a';
246 local $t->{NEEDS_LINKING} = 1;
247 $t->cflags();
248
249 # Brief bug where CCFLAGS was being blown away
250 is( $t->{CCFLAGS}, '-DMY_THING', 'cflags retains CCFLAGS' );
251}
252