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