This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix warning.
[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
52a0f4cc
A
40my $version = $ExtUtils::MM_Unix::VERSION;
41 $version =~ s/_//g;
42cmp_ok ($version, '>=', '1.12606', 'Should be at least version 1.12606');
c7a17d47
T
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
JH
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
T
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
c7a17d47
T
76 dist
77 dist_basics
78 dist_ci
79 dist_core
479d2113 80 distdir
c7a17d47
T
81 dist_test
82 dlsyms
83 dynamic
84 dynamic_bs
85 dynamic_lib
86 exescan
c7a17d47 87 extliblist
c7a17d47
T
88 find_perl
89 fixin
90 force
91 guess_name
c7a17d47
T
92 init_dirscan
93 init_main
94 init_others
95 install
96 installbin
c7a17d47
T
97 linkext
98 lsdir
99 macro
100 makeaperl
101 makefile
102 manifypods
c7a17d47 103 needs_linking
c7a17d47 104 pasthru
c7a17d47
T
105 perldepend
106 pm_to_blib
c7a17d47
T
107 ppd
108 prefixify
109 processPL
110 quote_paren
111 realclean
c7a17d47
T
112 static
113 static_lib
114 staticmake
115 subdir_x
116 subdirs
117 test
118 test_via_harness
119 test_via_script
120 tool_autosplit
121 tool_xsubpp
122 tools_other
123 top_targets
124 writedoc
125 xs_c
126 xs_cpp
127 xs_o
c7a17d47
T
128 / )
129 {
f6d6199c 130 can_ok($class, $_);
c7a17d47
T
131 }
132
f2cc0c2f
JH
133###############################################################################
134# some more detailed tests for the methods above
135
136ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
137
138###############################################################################
139# has_link_code tests
140
5c161494 141my $t = bless { NAME => "Foo" }, $class;
f2cc0c2f
JH
142$t->{HAS_LINK_CODE} = 1;
143is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
144
145$t->{HAS_LINK_CODE} = 0;
146is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
147
148delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
149is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
150
151delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
152is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
153
154delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
155is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
156
157delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
158is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
159
160###############################################################################
161# libscan
162
479d2113
MS
163is ($t->libscan('foo/RCS/bar'), '', 'libscan on RCS');
164is ($t->libscan('CVS/bar/car'), '', 'libscan on CVS');
165is ($t->libscan('SCCS'), '', 'libscan on SCCS');
166is ($t->libscan('.svn/something'), '', 'libscan on Subversion');
ad2f23df
JH
167is ($t->libscan('foo/b~r'), 'foo/b~r', 'libscan on file with ~');
168is ($t->libscan('foo/RCS.pm'), 'foo/RCS.pm', 'libscan on file with RCS');
479d2113
MS
169
170is ($t->libscan('Fatty'), 'Fatty', 'libscan on something not a VC file' );
f2cc0c2f
JH
171
172###############################################################################
173# maybe_command
174
a7d1454b
RGS
175open(FILE, ">command"); print FILE "foo"; close FILE;
176ok (!$t->maybe_command('command') ,"non executable file isn't a command");
177chmod 0755, "command";
178ok ($t->maybe_command('command'), "executable file is a command");
179unlink "command";
f2cc0c2f
JH
180
181###############################################################################
182# nicetext (dummy method)
183
184is ($t->nicetext('LOTR'),'LOTR','nicetext');
185
f2cc0c2f
JH
186
187###############################################################################
188# perl_script (on unix any ordinary, readable file)
189
a7d1454b
RGS
190my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t'
191 : 'MM_Unix.t';
f2cc0c2f
JH
192is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
193
194###############################################################################
195# perm_rw perm_rwx
196
479d2113 197$t->init_PERM;
f2cc0c2f
JH
198is ($t->perm_rw(),'644', 'perm_rw() is 644');
199is ($t->perm_rwx(),'755', 'perm_rwx() is 755');
200
201###############################################################################
202# post_constants, postamble, post_initialize
203
204foreach (qw/ post_constants postamble post_initialize/)
205 {
206 is ($t->$_(),'', "$_() is an empty string");
207 }
208
209###############################################################################
210# replace_manpage_separator
211
212is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator');
213
214###############################################################################
f2cc0c2f 215
479d2113 216$t->init_linker;
60537fc0 217foreach (qw/ EXPORT_LIST PERL_ARCHIVE PERL_ARCHIVE_AFTER /)
479d2113
MS
218{
219 ok( exists $t->{$_}, "$_ was defined" );
60537fc0 220 is( $t->{$_}, '', "$_ is empty on Unix");
479d2113 221}
f2cc0c2f 222
c7a17d47 223
5c161494
MS
224{
225 $t->{CCFLAGS} = '-DMY_THING';
226 $t->{LIBPERL_A} = 'libperl.a';
227 $t->{LIB_EXT} = '.a';
228 local $t->{NEEDS_LINKING} = 1;
229 $t->cflags();
230
231 # Brief bug where CCFLAGS was being blown away
232 is( $t->{CCFLAGS}, '-DMY_THING', 'cflags retains CCFLAGS' );
233}
234