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' ); }
27 use vars qw($VERSION);
32 my $class = 'ExtUtils::MM_Unix';
34 # only one of the following can be true
35 # test should be removed if MM_Unix ever stops handling other OS than Unix
36 my $os = ($ExtUtils::MM_Unix::Is_OS2 || 0)
37 + ($ExtUtils::MM_Unix::Is_Mac || 0)
38 + ($ExtUtils::MM_Unix::Is_Win32 || 0)
39 + ($ExtUtils::MM_Unix::Is_Dos || 0)
40 + ($ExtUtils::MM_Unix::Is_VMS || 0);
41 ok ( $os <= 1, 'There can be only one (or none)');
43 cmp_ok ($ExtUtils::MM_Unix::VERSION, '>=', '1.12606', 'Should be at least version 1.12606');
45 # when the following calls like canonpath, catdir etc are replaced by
46 # File::Spec calls, the test's become a bit pointless
48 foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) )
50 is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_");
53 is ($class->catdir('xx','xx'), File::Spec->catdir('xx','xx'),
54 'catdir(xx, xx) => xx/xx');
55 is ($class->catfile('xx','xx','yy'), File::Spec->catfile('xx','xx','yy'),
56 'catfile(xx, xx) => xx/xx');
58 is ($class->file_name_is_absolute('Bombdadil'),
59 File::Spec->file_name_is_absolute('Bombdadil'),
60 'file_name_is_absolute()');
62 is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()');
64 foreach (qw/updir curdir rootdir/)
66 is ($class->$_(), File::Spec->$_(), $_ );
106 maybe_command_in_dirs
138 ###############################################################################
139 # some more detailed tests for the methods above
141 ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
143 ###############################################################################
144 # has_link_code tests
146 my $t = bless { NAME => "Foo" }, $class;
147 $t->{HAS_LINK_CODE} = 1;
148 is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
150 $t->{HAS_LINK_CODE} = 0;
151 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
153 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
154 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
156 delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
157 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
159 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
160 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
162 delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
163 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
165 ###############################################################################
168 is ($t->libscan('RCS'),'','libscan on RCS');
169 is ($t->libscan('CVS'),'','libscan on CVS');
170 is ($t->libscan('SCCS'),'','libscan on SCCS');
171 is ($t->libscan('Fatty'),'Fatty','libscan on something not RCS, CVS or SCCS');
173 ###############################################################################
176 is ($t->maybe_command('blargel'),undef,"'blargel' isn't a command");
178 ###############################################################################
179 # nicetext (dummy method)
181 is ($t->nicetext('LOTR'),'LOTR','nicetext');
183 ###############################################################################
186 my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t'
189 is( $t->parse_version($self_name), '0.02', 'parse_version on ourself');
192 '$VERSION = 0.0' => 0.0,
193 '$VERSION = -1.0' => -1.0,
194 '$VERSION = undef' => 'undef',
195 '$wibble = 1.0' => 'undef',
198 while( my($code, $expect) = each %versions ) {
199 open(FILE, ">VERSION.tmp") || die $!;
200 print FILE "$code\n";
203 is( $t->parse_version('VERSION.tmp'), $expect, $code );
205 unlink "VERSION.tmp";
209 ###############################################################################
210 # perl_script (on unix any ordinary, readable file)
212 is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
214 ###############################################################################
217 is ($t->perm_rw(),'644', 'perm_rw() is 644');
218 is ($t->perm_rwx(),'755', 'perm_rwx() is 755');
220 ###############################################################################
221 # post_constants, postamble, post_initialize
223 foreach (qw/ post_constants postamble post_initialize/)
225 is ($t->$_(),'', "$_() is an empty string");
228 ###############################################################################
229 # replace_manpage_separator
231 is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator');
233 ###############################################################################
234 # export_list, perl_archive, perl_archive_after
236 foreach (qw/ export_list perl_archive perl_archive_after/)
238 is ($t->$_(),'',"$_() is empty string on Unix");
243 $t->{CCFLAGS} = '-DMY_THING';
244 $t->{LIBPERL_A} = 'libperl.a';
245 $t->{LIB_EXT} = '.a';
246 local $t->{NEEDS_LINKING} = 1;
249 # Brief bug where CCFLAGS was being blown away
250 is( $t->{CCFLAGS}, '-DMY_THING', 'cflags retains CCFLAGS' );