This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to ExtUtils::MakeMaker 6.25
[perl5.git] / lib / ExtUtils / t / MM_Unix.t
CommitLineData
39234879 1#!/usr/bin/perl -w
c7a17d47
T
2
3BEGIN {
39234879 4 if( $ENV{PERL_CORE} ) {
64964e6d 5 chdir 't';
39234879
MS
6 @INC = '../lib';
7 }
f6d6199c
MS
8 else {
9 unshift @INC, 't/lib';
10 }
c7a17d47 11}
39234879 12chdir 't';
c7a17d47 13
87a750c3
JH
14BEGIN {
15 use Test::More;
16
85c35b1b 17 if( $^O =~ /^VMS|os2|MacOS|MSWin32|cygwin|beos|netware$/i ) {
87a750c3
JH
18 plan skip_all => 'Non-Unix platform';
19 }
20 else {
a7d1454b 21 plan tests => 110;
87a750c3
JH
22 }
23}
c7a17d47
T
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
T
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
f2cc0c2f 40cmp_ok ($ExtUtils::MM_Unix::VERSION, '>=', '1.12606', 'Should be at least version 1.12606');
c7a17d47
T
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
JH
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
T
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
T
74 dist
75 dist_basics
76 dist_ci
77 dist_core
479d2113 78 distdir
c7a17d47
T
79 dist_test
80 dlsyms
81 dynamic
82 dynamic_bs
83 dynamic_lib
84 exescan
c7a17d47 85 extliblist
c7a17d47
T
86 find_perl
87 fixin
88 force
89 guess_name
c7a17d47
T
90 init_dirscan
91 init_main
92 init_others
93 install
94 installbin
c7a17d47
T
95 linkext
96 lsdir
97 macro
98 makeaperl
99 makefile
100 manifypods
c7a17d47 101 needs_linking
c7a17d47 102 pasthru
c7a17d47
T
103 perldepend
104 pm_to_blib
c7a17d47
T
105 ppd
106 prefixify
107 processPL
108 quote_paren
109 realclean
c7a17d47
T
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
T
126 / )
127 {
f6d6199c 128 can_ok($class, $_);
c7a17d47
T
129 }
130
f2cc0c2f
JH
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
JH
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
MS
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
JH
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
MS
167
168is ($t->libscan('Fatty'), 'Fatty', 'libscan on something not a VC file' );
f2cc0c2f
JH
169
170###############################################################################
171# maybe_command
172
a7d1454b
RGS
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
JH
178
179###############################################################################
180# nicetext (dummy method)
181
182is ($t->nicetext('LOTR'),'LOTR','nicetext');
183
f2cc0c2f
JH
184
185###############################################################################
186# perl_script (on unix any ordinary, readable file)
187
a7d1454b
RGS
188my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t'
189 : 'MM_Unix.t';
f2cc0c2f
JH
190is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
191
192###############################################################################
193# perm_rw perm_rwx
194
479d2113 195$t->init_PERM;
f2cc0c2f
JH
196is ($t->perm_rw(),'644', 'perm_rw() is 644');
197is ($t->perm_rwx(),'755', 'perm_rwx() is 755');
198
199###############################################################################
200# post_constants, postamble, post_initialize
201
202foreach (qw/ post_constants postamble post_initialize/)
203 {
204 is ($t->$_(),'', "$_() is an empty string");
205 }
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
MS
216{
217 ok( exists $t->{$_}, "$_ was defined" );
60537fc0 218 is( $t->{$_}, '', "$_ is empty on Unix");
479d2113 219}
f2cc0c2f 220
c7a17d47 221
5c161494
MS
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