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