ExtUtils::MakeMaker 6.55_02
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / MM_Unix.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4     if( $ENV{PERL_CORE} ) {
5         chdir 't';
6         @INC = '../lib';
7     }
8     else {
9         unshift @INC, 't/lib';
10     }
11 }
12 chdir 't';
13
14 BEGIN { 
15     use Test::More; 
16
17     if( $^O =~ /^VMS|os2|MacOS|MSWin32|cygwin|beos|netware$/i ) {
18         plan skip_all => 'Non-Unix platform';
19     }
20     else {
21         plan tests => 110;
22     }
23 }
24
25 BEGIN { use_ok( 'ExtUtils::MM_Unix' ); }
26
27 use strict;
28 use File::Spec;
29
30 my $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
34 my $os =  ($ExtUtils::MM_Unix::Is{OS2}   || 0)
35         + ($ExtUtils::MM_Unix::Is{Win32} || 0) 
36         + ($ExtUtils::MM_Unix::Is{Dos}   || 0)
37         + ($ExtUtils::MM_Unix::Is{VMS}   || 0); 
38 cmp_ok ( $os, '<=', 1,  'There can be only one (or none)');
39
40 is($ExtUtils::MM_Unix::VERSION, $ExtUtils::MakeMaker::VERSION, 'MM_Unix has a $VERSION');
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
45 foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) ) {
46     is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_");
47 }
48
49 is ($class->catdir('xx','xx'), File::Spec->catdir('xx','xx'),
50      'catdir(xx, xx) => xx/xx');
51 is ($class->catfile('xx','xx','yy'), File::Spec->catfile('xx','xx','yy'),
52      'catfile(xx, xx) => xx/xx');
53
54 is ($class->file_name_is_absolute('Bombdadil'), 
55     File::Spec->file_name_is_absolute('Bombdadil'),
56      'file_name_is_absolute()');
57
58 is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()');
59
60 foreach (qw/updir curdir rootdir/)
61   {
62   is ($class->$_(), File::Spec->$_(), $_ );
63   }
64
65 foreach ( qw /
66   c_o
67   clean
68   const_cccmd
69   const_config
70   const_loadlibs
71   constants
72   depend
73   dist
74   dist_basics
75   dist_ci
76   dist_core
77   distdir
78   dist_test
79   dlsyms
80   dynamic
81   dynamic_bs
82   dynamic_lib
83   exescan
84   extliblist
85   find_perl
86   fixin
87   force
88   guess_name
89   init_dirscan
90   init_main
91   init_others
92   install
93   installbin
94   linkext
95   lsdir
96   macro
97   makeaperl
98   makefile
99   manifypods
100   needs_linking
101   pasthru
102   perldepend
103   pm_to_blib
104   ppd
105   prefixify
106   processPL
107   quote_paren
108   realclean
109   static
110   static_lib
111   staticmake
112   subdir_x
113   subdirs
114   test
115   test_via_harness
116   test_via_script
117   tool_autosplit
118   tool_xsubpp
119   tools_other
120   top_targets
121   writedoc
122   xs_c
123   xs_cpp
124   xs_o
125   / )
126   {
127       can_ok($class, $_);
128   }
129
130 ###############################################################################
131 # some more detailed tests for the methods above
132
133 ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
134
135 ###############################################################################
136 # has_link_code tests
137
138 my $t = bless { NAME => "Foo" }, $class;
139 $t->{HAS_LINK_CODE} = 1; 
140 is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
141
142 $t->{HAS_LINK_CODE} = 0;
143 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
144
145 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
146 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
147
148 delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
149 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
150
151 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
152 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
153
154 delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
155 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
156
157 ###############################################################################
158 # libscan
159
160 is ($t->libscan('foo/RCS/bar'),     '', 'libscan on RCS');
161 is ($t->libscan('CVS/bar/car'),     '', 'libscan on CVS');
162 is ($t->libscan('SCCS'),            '', 'libscan on SCCS');
163 is ($t->libscan('.svn/something'),  '', 'libscan on Subversion');
164 is ($t->libscan('foo/b~r'),         'foo/b~r',    'libscan on file with ~');
165 is ($t->libscan('foo/RCS.pm'),      'foo/RCS.pm', 'libscan on file with RCS');
166
167 is ($t->libscan('Fatty'), 'Fatty', 'libscan on something not a VC file' );
168
169 ###############################################################################
170 # maybe_command
171
172 open(FILE, ">command"); print FILE "foo"; close FILE;
173 SKIP: {
174     skip("no separate execute mode on VOS", 2) if $^O eq "vos";
175
176     ok !$t->maybe_command('command') ,"non executable file isn't a command";
177
178     chmod 0755, "command";
179     ok ($t->maybe_command('command'),        "executable file is a command");
180 }
181 unlink "command";
182
183
184 ###############################################################################
185 # perl_script (on unix any ordinary, readable file)
186
187 my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t' 
188                                  : 'MM_Unix.t';
189 is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
190
191 ###############################################################################
192 # PERM_RW and PERM_RWX
193
194 $t->init_PERM;
195 is ($t->{PERM_RW},'644', 'PERM_RW is 644');
196 is ($t->{PERM_RWX},'755', 'PERM_RWX is 755');
197 is ($t->{PERM_DIR},'755', 'PERM_DIR is 755');
198
199
200 ###############################################################################
201 # post_constants, postamble, post_initialize
202
203 foreach (qw/ post_constants postamble post_initialize/) {
204   is ($t->$_(),'', "$_() is an empty string");
205 }
206
207 ###############################################################################
208 # replace_manpage_separator 
209
210 is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator'); 
211
212 ###############################################################################
213
214 $t->init_linker;
215 foreach (qw/ EXPORT_LIST PERL_ARCHIVE PERL_ARCHIVE_AFTER /)
216 {
217     ok( exists $t->{$_}, "$_ was defined" );
218     is( $t->{$_}, '', "$_ is empty on Unix"); 
219 }
220
221
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