This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fec24ca33651b1be08b28d88ab73eb3364c2c874
[perl5.git] / lib / ExtUtils / t / MM_Unix.t
1 #!./perl -w
2
3 # 2001-12-16 Tels first version
4 # 2002-01-13 Tels 0.02 added some tests for various functions, added Andreas
5 #                      fix to the version test (>= vs ==)
6 # 2002-01-14 Tels 0.03 exclude on beos and netware, /i for $^O test
7
8 BEGIN {
9     chdir 't' if -d 't';
10     @INC = '../lib';
11 }
12
13 BEGIN { 
14     use Test::More; 
15
16     if( $^O =~ /^VMS|os2|MacOS|MSWin32|cygwin|beos|netware$/i ) {
17         plan skip_all => 'Non-Unix platform';
18     }
19     else {
20         plan tests => 108; 
21     }
22 }
23
24 BEGIN { use_ok( 'ExtUtils::MM_Unix' ); }
25
26 $VERSION = '0.02';
27 use strict;
28 use File::Spec;
29
30 my $class = 'ExtUtils::MM_Unix';
31
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_Mac   || 0)
36         + ($ExtUtils::MM_Unix::Is_Win32 || 0) 
37         + ($ExtUtils::MM_Unix::Is_Dos   || 0)
38         + ($ExtUtils::MM_Unix::Is_VMS   || 0); 
39 ok ( $os <= 1,  'There can be only one (or none)');
40
41 cmp_ok ($ExtUtils::MM_Unix::VERSION, '>=', '1.12606', 'Should be at least version 1.12606');
42
43 # when the following calls like canonpath, catdir etc are replaced by
44 # File::Spec calls, the test's become a bit pointless
45
46 foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) )
47   {
48   is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_");
49   }
50
51 is ($class->catdir('xx','xx'), File::Spec->catdir('xx','xx'),
52      'catdir(xx, xx) => xx/xx');
53 is ($class->catfile('xx','xx','yy'), File::Spec->catfile('xx','xx','yy'),
54      'catfile(xx, xx) => xx/xx');
55
56 is ($class->file_name_is_absolute('Bombdadil'), 
57     File::Spec->file_name_is_absolute('Bombdadil'),
58      'file_name_is_absolute()');
59
60 is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()');
61
62 foreach (qw/updir curdir rootdir/)
63   {
64   is ($class->$_(), File::Spec->$_(), $_ );
65   }
66
67 foreach ( qw /
68   c_o
69   clean
70   const_cccmd
71   const_config
72   const_loadlibs
73   constants
74   depend
75   dir_target
76   dist
77   dist_basics
78   dist_ci
79   dist_core
80   dist_dir
81   dist_test
82   dlsyms
83   dynamic
84   dynamic_bs
85   dynamic_lib
86   exescan
87   export_list
88   extliblist
89   find_perl
90   fixin
91   force
92   guess_name
93   htmlifypods
94   init_dirscan
95   init_main
96   init_others
97   install
98   installbin
99   linkext
100   lsdir
101   macro
102   makeaperl
103   makefile
104   manifypods
105   maybe_command_in_dirs
106   needs_linking
107   pasthru
108   perldepend
109   pm_to_blib
110   ppd
111   prefixify
112   processPL
113   quote_paren
114   realclean
115   static
116   static_lib
117   staticmake
118   subdir_x
119   subdirs
120   test
121   test_via_harness
122   test_via_script
123   tool_autosplit
124   tool_xsubpp
125   tools_other
126   top_targets
127   writedoc
128   xs_c
129   xs_cpp
130   xs_o
131   xsubpp_version 
132   / )
133   {
134   ok ($class->can ($_), "can $_");
135   }
136
137 ###############################################################################
138 # some more detailed tests for the methods above
139
140 ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
141
142 ###############################################################################
143 # has_link_code tests
144
145 my $t = {}; bless $t,$class;
146 $t->{HAS_LINK_CODE} = 1; 
147 is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
148
149 $t->{HAS_LINK_CODE} = 0;
150 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
151
152 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
153 is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
154
155 delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
156 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
157
158 delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
159 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
160
161 delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
162 is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
163
164 ###############################################################################
165 # libscan
166
167 is ($t->libscan('RCS'),'','libscan on RCS');
168 is ($t->libscan('CVS'),'','libscan on CVS');
169 is ($t->libscan('SCCS'),'','libscan on SCCS');
170 is ($t->libscan('Fatty'),'Fatty','libscan on something not RCS, CVS or SCCS');
171
172 ###############################################################################
173 # maybe_command
174
175 is ($t->maybe_command('blargel'),undef,"'blargel' isn't a command");
176
177 ###############################################################################
178 # nicetext (dummy method)
179
180 is ($t->nicetext('LOTR'),'LOTR','nicetext');
181
182 ###############################################################################
183 # parse_version
184
185 my $self_name = '../lib/ExtUtils/t/MM_Unix.t';
186
187 is ($t->parse_version($self_name),'0.02',
188   'parse_version on ourself');
189
190 ###############################################################################
191 # perl_script (on unix any ordinary, readable file)
192
193 is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
194
195 ###############################################################################
196 # perm_rw perm_rwx
197
198 is ($t->perm_rw(),'644', 'perm_rw() is 644');
199 is ($t->perm_rwx(),'755', 'perm_rwx() is 755');
200
201 ###############################################################################
202 # post_constants, postamble, post_initialize
203
204 foreach (qw/ post_constants postamble post_initialize/)
205   {
206   is ($t->$_(),'', "$_() is an empty string");
207   }
208
209 ###############################################################################
210 # replace_manpage_separator 
211
212 is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator'); 
213
214 ###############################################################################
215 # export_list, perl_archive, perl_archive_after
216
217 foreach (qw/ export_list perl_archive perl_archive_after/)
218   {
219   is ($t->$_(),'',"$_() is empty string on Unix"); 
220   }
221
222