assorted VMS test fix-ups, $Config{prefixexp} revisited
[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' if -d 't';
6         @INC = '../lib';
7     }
8 }
9 chdir 't';
10
11 BEGIN { 
12     use Test::More; 
13
14     if( $^O =~ /^VMS|os2|MacOS|MSWin32|cygwin|beos|netware$/i ) {
15         plan skip_all => 'Non-Unix platform';
16     }
17     else {
18         plan tests => 108; 
19     }
20 }
21
22 BEGIN { use_ok( 'ExtUtils::MM_Unix' ); }
23
24 $VERSION = '0.02';
25 use strict;
26 use File::Spec;
27
28 my $class = 'ExtUtils::MM_Unix';
29
30 # only one of the following can be true
31 # test should be removed if MM_Unix ever stops handling other OS than Unix
32 my $os =  ($ExtUtils::MM_Unix::Is_OS2   || 0)
33         + ($ExtUtils::MM_Unix::Is_Mac   || 0)
34         + ($ExtUtils::MM_Unix::Is_Win32 || 0) 
35         + ($ExtUtils::MM_Unix::Is_Dos   || 0)
36         + ($ExtUtils::MM_Unix::Is_VMS   || 0); 
37 ok ( $os <= 1,  'There can be only one (or none)');
38
39 cmp_ok ($ExtUtils::MM_Unix::VERSION, '>=', '1.12606', 'Should be at least version 1.12606');
40
41 # when the following calls like canonpath, catdir etc are replaced by
42 # File::Spec calls, the test's become a bit pointless
43
44 foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) )
45   {
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   dir_target
74   dist
75   dist_basics
76   dist_ci
77   dist_core
78   dist_dir
79   dist_test
80   dlsyms
81   dynamic
82   dynamic_bs
83   dynamic_lib
84   exescan
85   export_list
86   extliblist
87   find_perl
88   fixin
89   force
90   guess_name
91   htmlifypods
92   init_dirscan
93   init_main
94   init_others
95   install
96   installbin
97   linkext
98   lsdir
99   macro
100   makeaperl
101   makefile
102   manifypods
103   maybe_command_in_dirs
104   needs_linking
105   pasthru
106   perldepend
107   pm_to_blib
108   ppd
109   prefixify
110   processPL
111   quote_paren
112   realclean
113   static
114   static_lib
115   staticmake
116   subdir_x
117   subdirs
118   test
119   test_via_harness
120   test_via_script
121   tool_autosplit
122   tool_xsubpp
123   tools_other
124   top_targets
125   writedoc
126   xs_c
127   xs_cpp
128   xs_o
129   xsubpp_version 
130   / )
131   {
132   ok ($class->can ($_), "can $_");
133   }
134
135 ###############################################################################
136 # some more detailed tests for the methods above
137
138 ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
139
140 ###############################################################################
141 # has_link_code tests
142
143 my $t = {}; bless $t,$class;
144 $t->{HAS_LINK_CODE} = 1; 
145 is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
146
147 $t->{HAS_LINK_CODE} = 0;
148 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
149
150 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
151 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
152
153 delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
154 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
155
156 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
157 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
158
159 delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
160 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
161
162 ###############################################################################
163 # libscan
164
165 is ($t->libscan('RCS'),'','libscan on RCS');
166 is ($t->libscan('CVS'),'','libscan on CVS');
167 is ($t->libscan('SCCS'),'','libscan on SCCS');
168 is ($t->libscan('Fatty'),'Fatty','libscan on something not RCS, CVS or SCCS');
169
170 ###############################################################################
171 # maybe_command
172
173 is ($t->maybe_command('blargel'),undef,"'blargel' isn't a command");
174
175 ###############################################################################
176 # nicetext (dummy method)
177
178 is ($t->nicetext('LOTR'),'LOTR','nicetext');
179
180 ###############################################################################
181 # parse_version
182
183 my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t' 
184                                 : 'MM_Unix.t';
185
186 is ($t->parse_version($self_name),'0.02',
187   'parse_version on ourself');
188
189 ###############################################################################
190 # perl_script (on unix any ordinary, readable file)
191
192 is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
193
194 ###############################################################################
195 # perm_rw perm_rwx
196
197 is ($t->perm_rw(),'644', 'perm_rw() is 644');
198 is ($t->perm_rwx(),'755', 'perm_rwx() is 755');
199
200 ###############################################################################
201 # post_constants, postamble, post_initialize
202
203 foreach (qw/ post_constants postamble post_initialize/)
204   {
205   is ($t->$_(),'', "$_() is an empty string");
206   }
207
208 ###############################################################################
209 # replace_manpage_separator 
210
211 is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator'); 
212
213 ###############################################################################
214 # export_list, perl_archive, perl_archive_after
215
216 foreach (qw/ export_list perl_archive perl_archive_after/)
217   {
218   is ($t->$_(),'',"$_() is empty string on Unix"); 
219   }
220
221