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); |
2e65e370 |
38 | cmp_ok ( $os, '<=', 1, 'There can be only one (or none)'); |
c7a17d47 |
39 | |
2e65e370 |
40 | is($ExtUtils::MM_Unix::VERSION, $ExtUtils::MakeMaker::VERSION, 'MM_Unix has a $VERSION'); |
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 | |
2e65e370 |
45 | foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) ) { |
46 | is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_"); |
47 | } |
c7a17d47 |
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 | |
f2cc0c2f |
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 | |
c7a17d47 |
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 |
c7a17d47 |
73 | dist |
74 | dist_basics |
75 | dist_ci |
76 | dist_core |
479d2113 |
77 | distdir |
c7a17d47 |
78 | dist_test |
79 | dlsyms |
80 | dynamic |
81 | dynamic_bs |
82 | dynamic_lib |
83 | exescan |
c7a17d47 |
84 | extliblist |
c7a17d47 |
85 | find_perl |
86 | fixin |
87 | force |
88 | guess_name |
c7a17d47 |
89 | init_dirscan |
90 | init_main |
91 | init_others |
92 | install |
93 | installbin |
c7a17d47 |
94 | linkext |
95 | lsdir |
96 | macro |
97 | makeaperl |
98 | makefile |
99 | manifypods |
c7a17d47 |
100 | needs_linking |
c7a17d47 |
101 | pasthru |
c7a17d47 |
102 | perldepend |
103 | pm_to_blib |
c7a17d47 |
104 | ppd |
105 | prefixify |
106 | processPL |
107 | quote_paren |
108 | realclean |
c7a17d47 |
109 | static |
110 | static_lib |
111 | staticmake |
112 | subdir_x |
113 | subdirs |
114 | test |
115 | test_via_harness |
116 | test_via_script |
117 | tool_autosplit |
118 | tool_xsubpp |
119 | tools_other |
120 | top_targets |
121 | writedoc |
122 | xs_c |
123 | xs_cpp |
124 | xs_o |
c7a17d47 |
125 | / ) |
126 | { |
f6d6199c |
127 | can_ok($class, $_); |
c7a17d47 |
128 | } |
129 | |
f2cc0c2f |
130 | ############################################################################### |
131 | # some more detailed tests for the methods above |
132 | |
133 | ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck'); |
134 | |
135 | ############################################################################### |
136 | # has_link_code tests |
137 | |
5c161494 |
138 | my $t = bless { NAME => "Foo" }, $class; |
f2cc0c2f |
139 | $t->{HAS_LINK_CODE} = 1; |
140 | is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1); |
141 | |
142 | $t->{HAS_LINK_CODE} = 0; |
143 | is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0); |
144 | |
145 | delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; |
146 | is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0); |
147 | |
148 | delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1; |
149 | is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1); |
150 | |
151 | delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1; |
152 | is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1); |
153 | |
154 | delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ]; |
155 | is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1); |
156 | |
157 | ############################################################################### |
158 | # libscan |
159 | |
479d2113 |
160 | is ($t->libscan('foo/RCS/bar'), '', 'libscan on RCS'); |
161 | is ($t->libscan('CVS/bar/car'), '', 'libscan on CVS'); |
162 | is ($t->libscan('SCCS'), '', 'libscan on SCCS'); |
163 | is ($t->libscan('.svn/something'), '', 'libscan on Subversion'); |
ad2f23df |
164 | is ($t->libscan('foo/b~r'), 'foo/b~r', 'libscan on file with ~'); |
165 | is ($t->libscan('foo/RCS.pm'), 'foo/RCS.pm', 'libscan on file with RCS'); |
479d2113 |
166 | |
167 | is ($t->libscan('Fatty'), 'Fatty', 'libscan on something not a VC file' ); |
f2cc0c2f |
168 | |
169 | ############################################################################### |
170 | # maybe_command |
171 | |
a7d1454b |
172 | open(FILE, ">command"); print FILE "foo"; close FILE; |
3722f0dc |
173 | SKIP: { |
174 | skip ("no separate execute mode", 1) if ($^O eq "vos"); |
a7d1454b |
175 | ok (!$t->maybe_command('command') ,"non executable file isn't a command"); |
3722f0dc |
176 | } |
177 | |
a7d1454b |
178 | chmod 0755, "command"; |
179 | ok ($t->maybe_command('command'), "executable file is a command"); |
180 | unlink "command"; |
f2cc0c2f |
181 | |
f2cc0c2f |
182 | |
183 | ############################################################################### |
184 | # perl_script (on unix any ordinary, readable file) |
185 | |
a7d1454b |
186 | my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t' |
187 | : 'MM_Unix.t'; |
f2cc0c2f |
188 | is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()'); |
189 | |
190 | ############################################################################### |
191 | # perm_rw perm_rwx |
192 | |
479d2113 |
193 | $t->init_PERM; |
f2cc0c2f |
194 | is ($t->perm_rw(),'644', 'perm_rw() is 644'); |
195 | is ($t->perm_rwx(),'755', 'perm_rwx() is 755'); |
196 | |
197 | ############################################################################### |
198 | # post_constants, postamble, post_initialize |
199 | |
2e65e370 |
200 | foreach (qw/ post_constants postamble post_initialize/) { |
f2cc0c2f |
201 | is ($t->$_(),'', "$_() is an empty string"); |
2e65e370 |
202 | } |
f2cc0c2f |
203 | |
204 | ############################################################################### |
205 | # replace_manpage_separator |
206 | |
207 | is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator'); |
208 | |
209 | ############################################################################### |
f2cc0c2f |
210 | |
479d2113 |
211 | $t->init_linker; |
60537fc0 |
212 | foreach (qw/ EXPORT_LIST PERL_ARCHIVE PERL_ARCHIVE_AFTER /) |
479d2113 |
213 | { |
214 | ok( exists $t->{$_}, "$_ was defined" ); |
60537fc0 |
215 | is( $t->{$_}, '', "$_ is empty on Unix"); |
479d2113 |
216 | } |
f2cc0c2f |
217 | |
c7a17d47 |
218 | |
5c161494 |
219 | { |
220 | $t->{CCFLAGS} = '-DMY_THING'; |
221 | $t->{LIBPERL_A} = 'libperl.a'; |
222 | $t->{LIB_EXT} = '.a'; |
223 | local $t->{NEEDS_LINKING} = 1; |
224 | $t->cflags(); |
225 | |
226 | # Brief bug where CCFLAGS was being blown away |
227 | is( $t->{CCFLAGS}, '-DMY_THING', 'cflags retains CCFLAGS' ); |
228 | } |
229 | |