5 if( $ENV{PERL_CORE} ) {
15 if ($^O =~ /MSWin32/i) {
18 plan skip_all => 'This is not Win32';
25 use ExtUtils::MakeMaker;
27 require_ok( 'ExtUtils::MM_Win32' );
29 # test import of $Verbose and &neatvalue
30 can_ok( 'MM', 'neatvalue' );
31 () = $ExtUtils::MM_Win32::Verbose;
32 () = $ExtUtils::MakeMaker::Verbose;
33 is( $ExtUtils::MM_Win32::Verbose, $ExtUtils::MakeMaker::Verbose,
34 'ExtUtils::MM_Win32 should import $Verbose from ExtUtils::MakeMaker' );
37 ##### Start new tests at the top of MM_Win32
39 # replace_manpage_separator() => tr|/|.|s ?
41 my $man = 'a/path/to//something';
42 ( my $replaced = $man ) =~ tr|/|.|s;
43 is( MM->replace_manpage_separator( $man ),
44 $replaced, 'replace_manpage_separator()' );
49 skip( '$ENV{COMSPEC} not set', 2 )
50 unless $ENV{COMSPEC} =~ m!((?:[a-z]:)?[^|<>]+)!i;
52 is( MM->maybe_command( $comspec ),
53 $comspec, 'COMSPEC is a maybe_command()' );
54 ( my $comspec2 = $comspec ) =~ s|\..{3}$||;
55 like( MM->maybe_command( $comspec2 ),
57 'maybe_command() without extension' );
60 local $ENV{PATHEXT} = '.exe';
61 ok( ! MM->maybe_command( 'not_a_command.com' ),
62 'not a maybe_command()' );
65 # file_name_is_absolute() [Does not support UNC-paths]
67 ok( MM->file_name_is_absolute( 'C:/' ),
68 'file_name_is_absolute()' );
69 ok( ! MM->file_name_is_absolute( 'some/path/' ),
70 'not file_name_is_absolute()' );
75 # Should be able to find running perl... $^X is OK on Win32
77 my $my_perl = $1 if $^X =~ /(.*)/; # are we in -T or -t?
78 my( $perl, $path ) = fileparse( $my_perl );
79 like( MM->find_perl( $], [ $perl ], [ $path ] ),
80 qr/^\Q$my_perl\E$/i, 'find_perl() finds this perl' );
83 # catdir() (calls MM_Win32->canonpath)
85 my @path_eg = qw( c: trick dir/now_OK );
87 is( MM->catdir( @path_eg ),
88 'C:\\trick\\dir\\now_OK', 'catdir()' );
89 is( MM->catdir( @path_eg ),
90 File::Spec->catdir( @path_eg ),
91 'catdir() eq File::Spec->catdir()' );
93 # catfile() (calls MM_Win32->catdir)
94 push @path_eg, 'file.ext';
96 is( MM->catfile( @path_eg ),
97 'C:\\trick\\dir\\now_OK\\file.ext', 'catfile()' );
99 is( MM->catfile( @path_eg ),
100 File::Spec->catfile( @path_eg ),
101 'catfile() eq File::Spec->catfile()' );
104 # init_others(): check if all keys are created and set?
105 # qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP TEST_F LD AR LDLOADLIBS DEV_NUL )
107 my $mm_w32 = bless( {}, 'MM' );
108 $mm_w32->init_others();
109 my @keys = qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP
110 TEST_F LD AR LDLOADLIBS DEV_NULL );
111 for my $key ( @keys ) {
112 ok( $mm_w32->{ $key }, "init_others: $key" );
119 NAME => 'TestMM_Win32',
121 VERSION_FROM => 'TestMM_Win32',
122 PM => { 'MM_Win32.pm' => 1 },
125 # XXX Hack until we have a proper init method.
126 # Flesh out some necessary keys in the MM object.
127 foreach my $key (qw(XS C O_FILES H HTMLLIBPODS HTMLSCRIPTPODS
128 MAN1PODS MAN3PODS PARENT_NAME)) {
129 $mm_w32->{$key} = '';
131 my $s_PM = join( " \\\n\t", sort keys %{$mm_w32->{PM}} );
132 my $k_PM = join( " \\\n\t", %{$mm_w32->{PM}} );
134 like( $mm_w32->constants(),
135 qr!^NAME\ =\ TestMM_Win32\s+VERSION\ =\ 1\.00.+
136 MAKEMAKER\ =\ \Q$INC{'ExtUtils/MakeMaker.pm'}\E\s+
137 MM_VERSION\ =\ \Q$ExtUtils::MakeMaker::VERSION\E.+
138 VERSION_FROM\ =\ TestMM_Win32.+
139 TO_INST_PM\ =\ \Q$s_PM\E\s+
140 PM_TO_BLIB\ =\ \Q$k_PM\E
141 !xs, 'constants()' );
147 my @path_eg = ( qw( . .. ), 'C:\\Program Files' );
148 local $ENV{PATH} = join ';', @path_eg;
149 ok( eq_array( [ MM->path() ], [ @path_eg ] ),
153 # static_lib() should look into that
154 # dynamic_bs() should look into that
155 # dynamic_lib() should look into that
159 my $clean = $Config{cc} =~ /^gcc/i ? 'dll.base dll.exp' : '*.pdb';
160 like( MM->clean(), qr/^clean ::\s+\Q-$(RM_F) $clean\E\s+$/m,
161 'clean() Makefile target' );
166 my $libperl = $Config{libperl} || 'libperl.a';
167 is( MM->perl_archive(), File::Spec->catfile('$(PERL_INC)', $libperl ),
168 'perl_archive() should respect libperl setting' );
173 my $mm_w32 = bless { BASEEXT => 'someext' }, 'ExtUtils::MM_Win32';
174 is( $mm_w32->export_list(), 'someext.def', 'export_list()' );
179 my $path = 'c:\\Program Files/SomeApp\\Progje.exe';
180 is( MM->canonpath( $path ), File::Spec->canonpath( $path ),
181 'canonpath() eq File::Spec->canonpath' );
186 my $script_name = 'mm_w32tmp';
189 skip( "Can't create temp file: $!", 4 )
190 unless open SCRIPT, "> $script_name";
191 print SCRIPT <<'EOSCRIPT';
195 skip( "Can't write to temp file: $!", 4 )
198 is( MM->perl_script( $script_name ),
199 "${script_name}$script_ext", "perl_script ($script_ext)" );
201 skip( "Can't rename temp file: $!", 3 )
202 unless rename $script_name, "${script_name}.pl";
204 is( MM->perl_script( $script_name ),
205 "${script_name}$script_ext", "perl_script ($script_ext)" );
207 skip( "Can't rename temp file: $!", 2 )
208 unless rename "${script_name}$script_ext", "${script_name}.bat";
209 $script_ext = '.bat';
210 is( MM->perl_script( $script_name ),
211 "${script_name}$script_ext", "perl_script ($script_ext)" );
213 skip( "Can't rename temp file: $!", 1 )
214 unless rename "${script_name}$script_ext", "${script_name}.noscript";
215 $script_ext = '.noscript';
217 isnt( MM->perl_script( $script_name ),
218 "${script_name}$script_ext",
219 "not a perl_script anymore ($script_ext)" );
220 is( MM->perl_script( $script_name ), undef,
221 "perl_script ($script_ext) returns empty" );
223 unlink "${script_name}$script_ext" if -f "${script_name}$script_ext";
228 like( MM->pm_to_blib(),
229 qr/^pm_to_blib: \Q$(TO_INST_PM)\E.+\Q$(TOUCH) \E\$@\s+$/ms,
235 like( MM->test_via_harness( $^X, 'MM_Win32.t' ),
236 qr/^\t\Q$^X\E \-Mblib.+"use Test::Harness.+MM_Win32.t\n$/,
237 'test_via_harness()' );
242 my %attribs = ( MAXLEN => 255 );
243 like( MM->tool_autosplit( %attribs ),
244 qr/^\#\ Usage:\ \$\(AUTOSPLITFILE\)
245 \ FileToSplit\ AutoDirToSplitInto.+
246 AUTOSPLITFILE\ =\ \$\(PERL\)\
247 "\-I\$\(PERL_ARCHLIB\)"\ "\-I\$\(PERL_LIB\)".+
248 \$AutoSplit::Maxlen=$attribs{MAXLEN};
250 'tool_autosplit()' );
255 ( my $mm_w32 = bless { }, 'MM' )->init_others();
257 my $bin_sh = ( $Config{make} =~ /^dmake/i
258 ? "" : ($Config{sh} || 'cmd /c') . "\n" );
259 $bin_sh = "SHELL = $bin_sh" if $bin_sh;
261 my $tools = join "\n", map "$_ = $mm_w32->{ $_ }"
262 => qw(CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL);
264 like( $mm_w32->tools_other(),
265 qr/^\Q$bin_sh$tools/m,
269 # xs_o() should look into that
270 # top_targets() should look into that
275 HTMLLIBPODS => { 'MM_Win32.pm' => 1 },
276 HTMLSCRIPTPODS => { 'MM_Win32.t' => 1 },
279 my $pods = join " \\\n\t", keys %{$mm_w32->{HTMLLIBPODS}},
280 keys %{$mm_w32->{HTMLSCRIPTPODS}};
282 my $pod2html_exe = $mm_w32->catfile($Config{scriptdirexp},'pod2html');
283 unless ( $pod2html_exe = $mm_w32->perl_script( $pod2html_exe ) ) {
284 $pod2html_exe = '-S pod2html';
287 like( $mm_w32->htmlifypods(),
288 qr/^POD2HTML_EXE\ =\ \Q$pod2html_exe\E\n
290 htmlifypods\ :\ pure_all\ \Q$pods\E
292 'htmlifypods() Makefile target' );
297 my $mm_w32 = bless { NOECHO => '' }, 'MM';
298 like( $mm_w32->manifypods(),
299 qr/^\nmanifypods :\n\t\$\Q(NOOP)\E\n$/,
300 'manifypods() Makefile target' );
303 # dist_ci() should look into that
304 # dist_core() should look into that
308 my $pastru = "PASTHRU = " . ($Config{make} =~ /^nmake/i ? "-nologo" : "");
309 is( MM->pasthru(), $pastru, 'pasthru()' );
315 bless(\(my $scalar), $_[0]);
327 MM_Win32.t - Tests for ExtUtils::MM_Win32
331 - Methods to still be checked:
332 # static_lib() should look into that
333 # dynamic_bs() should look into that
334 # dynamic_lib() should look into that
335 # xs_o() should look into that
336 # top_targets() should look into that
337 # dist_ci() should look into that
338 # dist_core() should look into that
342 20011228 Abe Timmerman <abe@ztreet.demon.nl>