11 if( $^O =~ /^VMS|os2|MacOS|MSWin32|cygwin|beos|netware$/i ) {
12 plan skip_all => 'Non-Unix platform';
19 BEGIN { use_ok( 'ExtUtils::MM_Unix' ); }
24 my $class = 'ExtUtils::MM_Unix';
26 # only one of the following can be true
27 # test should be removed if MM_Unix ever stops handling other OS than Unix
28 my $os = ($ExtUtils::MM_Unix::Is{OS2} || 0)
29 + ($ExtUtils::MM_Unix::Is{Win32} || 0)
30 + ($ExtUtils::MM_Unix::Is{Dos} || 0)
31 + ($ExtUtils::MM_Unix::Is{VMS} || 0);
32 cmp_ok ( $os, '<=', 1, 'There can be only one (or none)');
34 is($ExtUtils::MM_Unix::VERSION, $ExtUtils::MakeMaker::VERSION, 'MM_Unix has a $VERSION');
36 # when the following calls like canonpath, catdir etc are replaced by
37 # File::Spec calls, the test's become a bit pointless
39 foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) ) {
40 is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_");
43 is ($class->catdir('xx','xx'), File::Spec->catdir('xx','xx'),
44 'catdir(xx, xx) => xx/xx');
45 is ($class->catfile('xx','xx','yy'), File::Spec->catfile('xx','xx','yy'),
46 'catfile(xx, xx) => xx/xx');
48 is ($class->file_name_is_absolute('Bombdadil'),
49 File::Spec->file_name_is_absolute('Bombdadil'),
50 'file_name_is_absolute()');
52 is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()');
54 foreach (qw/updir curdir rootdir/)
56 is ($class->$_(), File::Spec->$_(), $_ );
124 ###############################################################################
125 # some more detailed tests for the methods above
127 ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
129 ###############################################################################
130 # has_link_code tests
132 my $t = bless { NAME => "Foo" }, $class;
133 $t->{HAS_LINK_CODE} = 1;
134 is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
136 $t->{HAS_LINK_CODE} = 0;
137 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
139 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
140 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
142 delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
143 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
145 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
146 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
148 delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
149 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
151 ###############################################################################
154 is ($t->libscan('foo/RCS/bar'), '', 'libscan on RCS');
155 is ($t->libscan('CVS/bar/car'), '', 'libscan on CVS');
156 is ($t->libscan('SCCS'), '', 'libscan on SCCS');
157 is ($t->libscan('.svn/something'), '', 'libscan on Subversion');
158 is ($t->libscan('foo/b~r'), 'foo/b~r', 'libscan on file with ~');
159 is ($t->libscan('foo/RCS.pm'), 'foo/RCS.pm', 'libscan on file with RCS');
161 is ($t->libscan('Fatty'), 'Fatty', 'libscan on something not a VC file' );
163 ###############################################################################
166 open(FILE, ">command"); print FILE "foo"; close FILE;
168 skip("no separate execute mode on VOS", 2) if $^O eq "vos";
170 ok !$t->maybe_command('command') ,"non executable file isn't a command";
172 chmod 0755, "command";
173 ok ($t->maybe_command('command'), "executable file is a command");
178 ###############################################################################
179 # perl_script (on unix any ordinary, readable file)
181 my $self_name = 'MM_Unix.t';
182 is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
184 ###############################################################################
185 # PERM_RW and PERM_RWX
188 is ($t->{PERM_RW},'644', 'PERM_RW is 644');
189 is ($t->{PERM_RWX},'755', 'PERM_RWX is 755');
190 is ($t->{PERM_DIR},'755', 'PERM_DIR is 755');
193 ###############################################################################
194 # post_constants, postamble, post_initialize
196 foreach (qw/ post_constants postamble post_initialize/) {
197 is ($t->$_(),'', "$_() is an empty string");
200 ###############################################################################
201 # replace_manpage_separator
203 is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator');
205 ###############################################################################
208 foreach (qw/ EXPORT_LIST PERL_ARCHIVE PERL_ARCHIVE_AFTER /)
210 ok( exists $t->{$_}, "$_ was defined" );
211 is( $t->{$_}, '', "$_ is empty on Unix");
216 $t->{CCFLAGS} = '-DMY_THING';
217 $t->{LIBPERL_A} = 'libperl.a';
218 $t->{LIB_EXT} = '.a';
219 local $t->{NEEDS_LINKING} = 1;
222 # Brief bug where CCFLAGS was being blown away
223 like( $t->{CCFLAGS}, qr/\-DMY_THING/, 'cflags retains CCFLAGS' );