1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
#!/usr/bin/perl -w
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't' if -d 't';
@INC = '../lib';
}
else {
unshift @INC, 't/lib';
}
}
chdir 't';
BEGIN {
use Test::More;
if( $^O =~ /^VMS|os2|MacOS|MSWin32|cygwin|beos|netware$/i ) {
plan skip_all => 'Non-Unix platform';
}
else {
plan tests => 112;
}
}
BEGIN { use_ok( 'ExtUtils::MM_Unix' ); }
$VERSION = '0.02';
use strict;
use File::Spec;
my $class = 'ExtUtils::MM_Unix';
# only one of the following can be true
# test should be removed if MM_Unix ever stops handling other OS than Unix
my $os = ($ExtUtils::MM_Unix::Is_OS2 || 0)
+ ($ExtUtils::MM_Unix::Is_Mac || 0)
+ ($ExtUtils::MM_Unix::Is_Win32 || 0)
+ ($ExtUtils::MM_Unix::Is_Dos || 0)
+ ($ExtUtils::MM_Unix::Is_VMS || 0);
ok ( $os <= 1, 'There can be only one (or none)');
cmp_ok ($ExtUtils::MM_Unix::VERSION, '>=', '1.12606', 'Should be at least version 1.12606');
# when the following calls like canonpath, catdir etc are replaced by
# File::Spec calls, the test's become a bit pointless
foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) )
{
is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_");
}
is ($class->catdir('xx','xx'), File::Spec->catdir('xx','xx'),
'catdir(xx, xx) => xx/xx');
is ($class->catfile('xx','xx','yy'), File::Spec->catfile('xx','xx','yy'),
'catfile(xx, xx) => xx/xx');
is ($class->file_name_is_absolute('Bombdadil'),
File::Spec->file_name_is_absolute('Bombdadil'),
'file_name_is_absolute()');
is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()');
foreach (qw/updir curdir rootdir/)
{
is ($class->$_(), File::Spec->$_(), $_ );
}
foreach ( qw /
c_o
clean
const_cccmd
const_config
const_loadlibs
constants
depend
dir_target
dist
dist_basics
dist_ci
dist_core
dist_dir
dist_test
dlsyms
dynamic
dynamic_bs
dynamic_lib
exescan
export_list
extliblist
find_perl
fixin
force
guess_name
init_dirscan
init_main
init_others
install
installbin
linkext
lsdir
macro
makeaperl
makefile
manifypods
maybe_command_in_dirs
needs_linking
pasthru
perldepend
pm_to_blib
ppd
prefixify
processPL
quote_paren
realclean
static
static_lib
staticmake
subdir_x
subdirs
test
test_via_harness
test_via_script
tool_autosplit
tool_xsubpp
tools_other
top_targets
writedoc
xs_c
xs_cpp
xs_o
xsubpp_version
/ )
{
can_ok($class, $_);
}
###############################################################################
# some more detailed tests for the methods above
ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
###############################################################################
# has_link_code tests
my $t = bless { NAME => "Foo" }, $class;
$t->{HAS_LINK_CODE} = 1;
is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
$t->{HAS_LINK_CODE} = 0;
is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
###############################################################################
# libscan
is ($t->libscan('RCS'),'','libscan on RCS');
is ($t->libscan('CVS'),'','libscan on CVS');
is ($t->libscan('SCCS'),'','libscan on SCCS');
is ($t->libscan('Fatty'),'Fatty','libscan on something not RCS, CVS or SCCS');
###############################################################################
# maybe_command
is ($t->maybe_command('blargel'),undef,"'blargel' isn't a command");
###############################################################################
# nicetext (dummy method)
is ($t->nicetext('LOTR'),'LOTR','nicetext');
###############################################################################
# parse_version
my $self_name = $ENV{PERL_CORE} ? '../lib/ExtUtils/t/MM_Unix.t'
: 'MM_Unix.t';
is( $t->parse_version($self_name), '0.02', 'parse_version on ourself');
my %versions = (
'$VERSION = 0.0' => 0.0,
'$VERSION = -1.0' => -1.0,
'$VERSION = undef' => 'undef',
'$wibble = 1.0' => 'undef',
);
while( my($code, $expect) = each %versions ) {
open(FILE, ">VERSION.tmp") || die $!;
print FILE "$code\n";
close FILE;
is( $t->parse_version('VERSION.tmp'), $expect, $code );
unlink "VERSION.tmp";
}
###############################################################################
# perl_script (on unix any ordinary, readable file)
is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
###############################################################################
# perm_rw perm_rwx
is ($t->perm_rw(),'644', 'perm_rw() is 644');
is ($t->perm_rwx(),'755', 'perm_rwx() is 755');
###############################################################################
# post_constants, postamble, post_initialize
foreach (qw/ post_constants postamble post_initialize/)
{
is ($t->$_(),'', "$_() is an empty string");
}
###############################################################################
# replace_manpage_separator
is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator');
###############################################################################
# export_list, perl_archive, perl_archive_after
foreach (qw/ export_list perl_archive perl_archive_after/)
{
is ($t->$_(),'',"$_() is empty string on Unix");
}
{
$t->{CCFLAGS} = '-DMY_THING';
$t->{LIBPERL_A} = 'libperl.a';
$t->{LIB_EXT} = '.a';
local $t->{NEEDS_LINKING} = 1;
$t->cflags();
# Brief bug where CCFLAGS was being blown away
is( $t->{CCFLAGS}, '-DMY_THING', 'cflags retains CCFLAGS' );
}
|