Commit | Line | Data |
39234879 |
1 | #!/usr/bin/perl -w |
c7a17d47 |
2 | |
3 | BEGIN { |
39234879 |
4 | if( $ENV{PERL_CORE} ) { |
64964e6d |
5 | chdir 't'; |
39234879 |
6 | @INC = '../lib'; |
7 | } |
f6d6199c |
8 | else { |
9 | unshift @INC, 't/lib'; |
10 | } |
c7a17d47 |
11 | } |
39234879 |
12 | chdir 't'; |
c7a17d47 |
13 | |
87a750c3 |
14 | BEGIN { |
15 | use Test::More; |
16 | |
85c35b1b |
17 | if( $^O =~ /^VMS|os2|MacOS|MSWin32|cygwin|beos|netware$/i ) { |
87a750c3 |
18 | plan skip_all => 'Non-Unix platform'; |
19 | } |
20 | else { |
3a0105ce |
21 | plan tests => 109; |
87a750c3 |
22 | } |
23 | } |
c7a17d47 |
24 | |
25 | BEGIN { use_ok( 'ExtUtils::MM_Unix' ); } |
26 | |
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 |
a592ba15 |
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); |
c7a17d47 |
38 | ok ( $os <= 1, 'There can be only one (or none)'); |
39 | |
c8d65f10 |
40 | cmp_ok ($ExtUtils::MM_Unix::VERSION, '>=', '1.12606', 'Should be at least version 1.12606'); |
c7a17d47 |
41 | |
42 | # when the following calls like canonpath, catdir etc are replaced by |
43 | # File::Spec calls, the test's become a bit pointless |
44 | |
45 | foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) ) |
46 | { |
47 | is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_"); |
48 | } |
49 | |
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'); |
54 | |
f2cc0c2f |
55 | is ($class->file_name_is_absolute('Bombdadil'), |
56 | File::Spec->file_name_is_absolute('Bombdadil'), |
57 | 'file_name_is_absolute()'); |
58 | |
59 | is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()'); |
60 | |
c7a17d47 |
61 | foreach (qw/updir curdir rootdir/) |
62 | { |
63 | is ($class->$_(), File::Spec->$_(), $_ ); |
64 | } |
65 | |
66 | foreach ( qw / |
67 | c_o |
68 | clean |
69 | const_cccmd |
70 | const_config |
71 | const_loadlibs |
72 | constants |
73 | depend |
c7a17d47 |
74 | dist |
75 | dist_basics |
76 | dist_ci |
77 | dist_core |
479d2113 |
78 | distdir |
c7a17d47 |
79 | dist_test |
80 | dlsyms |
81 | dynamic |
82 | dynamic_bs |
83 | dynamic_lib |
84 | exescan |
c7a17d47 |
85 | extliblist |
c7a17d47 |
86 | find_perl |
87 | fixin |
88 | force |
89 | guess_name |
c7a17d47 |
90 | init_dirscan |
91 | init_main |
92 | init_others |
93 | install |
94 | installbin |
c7a17d47 |
95 | linkext |
96 | lsdir |
97 | macro |
98 | makeaperl |
99 | makefile |
100 | manifypods |
c7a17d47 |
101 | needs_linking |
c7a17d47 |
102 | pasthru |
c7a17d47 |
103 | perldepend |
104 | pm_to_blib |
c7a17d47 |
105 | ppd |
106 | prefixify |
107 | processPL |
108 | quote_paren |
109 | realclean |
c7a17d47 |
110 | static |
111 | static_lib |
112 | staticmake |
113 | subdir_x |
114 | subdirs |
115 | test |
116 | test_via_harness |
117 | test_via_script |
118 | tool_autosplit |
119 | tool_xsubpp |
120 | tools_other |
121 | top_targets |
122 | writedoc |
123 | xs_c |
124 | xs_cpp |
125 | xs_o |
c7a17d47 |
126 | / ) |
127 | { |
f6d6199c |
128 | can_ok($class, $_); |
c7a17d47 |
129 | } |
130 | |
f2cc0c2f |
131 | ############################################################################### |
132 | # some more detailed tests for the methods above |
133 | |
134 | ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck'); |
135 | |
136 | ############################################################################### |
137 | # has_link_code tests |
138 | |
5c161494 |
139 | my $t = bless { NAME => "Foo" }, $class; |
f2cc0c2f |
140 | $t->{HAS_LINK_CODE} = 1; |
141 | is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1); |
142 | |
143 | $t->{HAS_LINK_CODE} = 0; |
144 | is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0); |
145 | |
146 | delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; |
147 | is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0); |
148 | |
149 | delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1; |
150 | is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1); |
151 | |
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); |
154 | |
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); |
157 | |
158 | ############################################################################### |
159 | # libscan |
160 | |
479d2113 |
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'); |
ad2f23df |
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'); |
479d2113 |
167 | |
168 | is ($t->libscan('Fatty'), 'Fatty', 'libscan on something not a VC file' ); |
f2cc0c2f |
169 | |
170 | ############################################################################### |
171 | # maybe_command |
172 | |
a7d1454b |
173 | open(FILE, ">command"); print FILE "foo"; close FILE; |
3722f0dc |
174 | SKIP: { |
175 | skip ("no separate execute mode", 1) if ($^O eq "vos"); |
a7d1454b |
176 | ok (!$t->maybe_command('command') ,"non executable file isn't a command"); |
3722f0dc |
177 | } |
178 | |
a7d1454b |
179 | chmod 0755, "command"; |
180 | ok ($t->maybe_command('command'), "executable file is a command"); |
181 | unlink "command"; |
f2cc0c2f |
182 | |
f2cc0c2f |
183 | |
184 | ############################################################################### |
185 | # perl_script (on unix any ordinary, readable file) |
186 | |
a7d1454b |
187 | my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t' |
188 | : 'MM_Unix.t'; |
f2cc0c2f |
189 | is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()'); |
190 | |
191 | ############################################################################### |
192 | # perm_rw perm_rwx |
193 | |
479d2113 |
194 | $t->init_PERM; |
f2cc0c2f |
195 | is ($t->perm_rw(),'644', 'perm_rw() is 644'); |
196 | is ($t->perm_rwx(),'755', 'perm_rwx() is 755'); |
197 | |
198 | ############################################################################### |
199 | # post_constants, postamble, post_initialize |
200 | |
201 | foreach (qw/ post_constants postamble post_initialize/) |
202 | { |
203 | is ($t->$_(),'', "$_() is an empty string"); |
204 | } |
205 | |
206 | ############################################################################### |
207 | # replace_manpage_separator |
208 | |
209 | is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator'); |
210 | |
211 | ############################################################################### |
f2cc0c2f |
212 | |
479d2113 |
213 | $t->init_linker; |
60537fc0 |
214 | foreach (qw/ EXPORT_LIST PERL_ARCHIVE PERL_ARCHIVE_AFTER /) |
479d2113 |
215 | { |
216 | ok( exists $t->{$_}, "$_ was defined" ); |
60537fc0 |
217 | is( $t->{$_}, '', "$_ is empty on Unix"); |
479d2113 |
218 | } |
f2cc0c2f |
219 | |
c7a17d47 |
220 | |
5c161494 |
221 | { |
222 | $t->{CCFLAGS} = '-DMY_THING'; |
223 | $t->{LIBPERL_A} = 'libperl.a'; |
224 | $t->{LIB_EXT} = '.a'; |
225 | local $t->{NEEDS_LINKING} = 1; |
226 | $t->cflags(); |
227 | |
228 | # Brief bug where CCFLAGS was being blown away |
229 | is( $t->{CCFLAGS}, '-DMY_THING', 'cflags retains CCFLAGS' ); |
230 | } |
231 | |