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 ok ( $os <= 1, 'There can be only one (or none)');
40 cmp_ok ($ExtUtils::MM_Unix::VERSION, '>=', '1.12606', 'Should be at least version 1.12606');
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) )
47 is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_");
50 is ($class->catdir('xx','xx'), File::Spec->catdir('xx','xx'),
51 'catdir(xx, xx) => xx/xx');
52 is ($class->catfile('xx','xx','yy'), File::Spec->catfile('xx','xx','yy'),
53 'catfile(xx, xx) => xx/xx');
55 is ($class->file_name_is_absolute('Bombdadil'),
56 File::Spec->file_name_is_absolute('Bombdadil'),
57 'file_name_is_absolute()');
59 is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()');
61 foreach (qw/updir curdir rootdir/)
63 is ($class->$_(), File::Spec->$_(), $_ );
131 ###############################################################################
132 # some more detailed tests for the methods above
134 ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
136 ###############################################################################
137 # has_link_code tests
139 my $t = bless { NAME => "Foo" }, $class;
140 $t->{HAS_LINK_CODE} = 1;
141 is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
143 $t->{HAS_LINK_CODE} = 0;
144 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
146 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
147 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
149 delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
150 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
152 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
153 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
155 delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
156 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
158 ###############################################################################
161 is ($t->libscan('foo/RCS/bar'), '', 'libscan on RCS');
162 is ($t->libscan('CVS/bar/car'), '', 'libscan on CVS');
163 is ($t->libscan('SCCS'), '', 'libscan on SCCS');
164 is ($t->libscan('.svn/something'), '', 'libscan on Subversion');
165 is ($t->libscan('foo/b~r'), 'foo/b~r', 'libscan on file with ~');
166 is ($t->libscan('foo/RCS.pm'), 'foo/RCS.pm', 'libscan on file with RCS');
168 is ($t->libscan('Fatty'), 'Fatty', 'libscan on something not a VC file' );
170 ###############################################################################
173 open(FILE, ">command"); print FILE "foo"; close FILE;
174 ok (!$t->maybe_command('command') ,"non executable file isn't a command");
175 chmod 0755, "command";
176 ok ($t->maybe_command('command'), "executable file is a command");
179 ###############################################################################
180 # nicetext (dummy method)
182 is ($t->nicetext('LOTR'),'LOTR','nicetext');
185 ###############################################################################
186 # perl_script (on unix any ordinary, readable file)
188 my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t'
190 is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
192 ###############################################################################
196 is ($t->perm_rw(),'644', 'perm_rw() is 644');
197 is ($t->perm_rwx(),'755', 'perm_rwx() is 755');
199 ###############################################################################
200 # post_constants, postamble, post_initialize
202 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' );