4 if( $ENV{PERL_CORE} ) {
17 if( $^O =~ /^VMS|os2|MacOS|MSWin32|cygwin|beos|netware$/i ) {
18 plan skip_all => 'Non-Unix platform';
25 BEGIN { use_ok( 'ExtUtils::MM_Unix' ); }
30 my $class = 'ExtUtils::MM_Unix';
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)');
40 is($ExtUtils::MM_Unix::VERSION, $ExtUtils::MakeMaker::VERSION, 'MM_Unix has a $VERSION');
42 # when the following calls like canonpath, catdir etc are replaced by
43 # File::Spec calls, the test's become a bit pointless
45 foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) ) {
46 is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_");
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');
54 is ($class->file_name_is_absolute('Bombdadil'),
55 File::Spec->file_name_is_absolute('Bombdadil'),
56 'file_name_is_absolute()');
58 is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()');
60 foreach (qw/updir curdir rootdir/)
62 is ($class->$_(), File::Spec->$_(), $_ );
130 ###############################################################################
131 # some more detailed tests for the methods above
133 ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
135 ###############################################################################
136 # has_link_code tests
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);
142 $t->{HAS_LINK_CODE} = 0;
143 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
145 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
146 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
148 delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
149 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
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);
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);
157 ###############################################################################
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');
167 is ($t->libscan('Fatty'), 'Fatty', 'libscan on something not a VC file' );
169 ###############################################################################
172 open(FILE, ">command"); print FILE "foo"; close FILE;
174 skip("no separate execute mode on VOS", 2) if $^O eq "vos";
176 ok !$t->maybe_command('command') ,"non executable file isn't a command";
178 chmod 0755, "command";
179 ok ($t->maybe_command('command'), "executable file is a command");
184 ###############################################################################
185 # perl_script (on unix any ordinary, readable file)
187 my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t'
189 is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
191 ###############################################################################
192 # PERM_RW and PERM_RWX
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');
200 ###############################################################################
201 # post_constants, postamble, post_initialize
203 foreach (qw/ post_constants postamble post_initialize/) {
204 is ($t->$_(),'', "$_() is an empty string");
207 ###############################################################################
208 # replace_manpage_separator
210 is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator');
212 ###############################################################################
215 foreach (qw/ EXPORT_LIST PERL_ARCHIVE PERL_ARCHIVE_AFTER /)
217 ok( exists $t->{$_}, "$_ was defined" );
218 is( $t->{$_}, '', "$_ is empty on Unix");
223 $t->{CCFLAGS} = '-DMY_THING';
224 $t->{LIBPERL_A} = 'libperl.a';
225 $t->{LIB_EXT} = '.a';
226 local $t->{NEEDS_LINKING} = 1;
229 # Brief bug where CCFLAGS was being blown away
230 is( $t->{CCFLAGS}, '-DMY_THING', 'cflags retains CCFLAGS' );