12 if ($^O =~ /MSWin32/i) {
15 plan skip_all => 'Test irrelevant outside of MSWin32';
23 # Does this mimic ExtUtils::MakeMaker ok?
27 ExtUtils::Liblist::Kid
30 # MM package faked up by messy MI entanglement
35 require_ok( 'ExtUtils::MM_Win32' );
37 # test import of $Verbose and &neatvalue
38 can_ok( 'MM', 'neatvalue' );
39 is( $ExtUtils::MM_Win32::Verbose, $ExtUtils::MakeMaker::Verbose,
40 'ExtUtils::MM_Win32 should import $Verbose from ExtUtils::MakeMaker' );
43 ##### Start new tests at the top of MM_Win32
45 # replace_manpage_separator() => tr|/|.|s ?
47 my $man = 'a/path/to//something';
48 ( my $replaced = $man ) =~ tr|/|.|s;
49 is( MM->replace_manpage_separator( $man ),
50 $replaced, 'replace_manpage_separator()' );
55 skip( '$ENV{COMSPEC} not set', 2 )
56 unless $ENV{COMSPEC} =~ m!((?:[a-z]:)?[^|<>]+)!i;
58 is( MM->maybe_command( $comspec ),
59 $comspec, 'COMSPEC is a maybe_command()' );
60 ( my $comspec2 = $comspec ) =~ s|\..{3}$||;
61 like( MM->maybe_command( $comspec2 ),
63 'maybe_command() without extension' );
66 local $ENV{PATHEXT} = '.exe';
67 ok( ! MM->maybe_command( 'not_a_command.com' ),
68 'not a maybe_command()' );
71 # file_name_is_absolute() [Does not support UNC-paths]
73 ok( MM->file_name_is_absolute( 'C:/' ),
74 'file_name_is_absolute()' );
75 ok( ! MM->file_name_is_absolute( 'some/path/' ),
76 'not file_name_is_absolute()' );
81 # Should be able to find running perl... $^X is OK on Win32
83 my $my_perl = $1 if $^X =~ /(.*)/; # are we in -T or -t?
84 my( $perl, $path ) = fileparse( $my_perl );
85 like( MM->find_perl( $], [ $perl ], [ $path ] ),
86 qr/^\Q$my_perl\E$/i, 'find_perl() finds this perl' );
89 # catdir() (calls MM_Win32->canonpath)
91 my @path_eg = qw( c: trick dir/now_OK );
93 is( MM->catdir( @path_eg ),
94 'C:\\trick\\dir\\now_OK', 'catdir()' );
95 is( MM->catdir( @path_eg ),
96 File::Spec->catdir( @path_eg ),
97 'catdir() eq File::Spec->catdir()' );
99 # catfile() (calls MM_Win32->catdir)
100 push @path_eg, 'file.ext';
102 is( MM->catfile( @path_eg ),
103 'C:\\trick\\dir\\now_OK\\file.ext', 'catfile()' );
105 is( MM->catfile( @path_eg ),
106 File::Spec->catfile( @path_eg ),
107 'catfile() eq File::Spec->catfile()' );
110 # init_others(): check if all keys are created and set?
111 # qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP TEST_F LD AR LDLOADLIBS DEV_NUL )
113 my $mm_w32 = bless( {}, 'MM' );
114 $mm_w32->init_others();
115 my @keys = qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP
116 TEST_F LD AR LDLOADLIBS DEV_NULL );
117 for my $key ( @keys ) {
118 ok( $mm_w32->{ $key }, "init_others: $key" );
125 NAME => 'TestMM_Win32',
127 VERSION_FROM => 'TestMM_Win32',
128 PM => { 'MM_Win32.pm' => 1 },
130 my $s_PM = join( " \\\n\t", sort keys %{$mm_w32->{PM}} );
131 my $k_PM = join( " \\\n\t", %{$mm_w32->{PM}} );
133 like( $mm_w32->constants(),
134 qr/^NAME\ =\ TestMM_Win32\s+VERSION\ =\ 1\.00.+
135 MAKEMAKER\ =\ $INC{'ExtUtils\MakeMaker.pm'}\s+
136 MM_VERSION\ =\ $ExtUtils::MakeMaker::VERSION.+
137 VERSION_FROM\ =\ TestMM_Win32.+
138 TO_INST_PM\ =\ \Q$s_PM\E\s+
139 PM_TO_BLIB\ =\ \Q$k_PM\E
140 /xs, 'constants()' );
146 my @path_eg = ( qw( . .. ), 'C:\\Program Files' );
147 local $ENV{PATH} = join ';', @path_eg;
148 ok( eq_array( [ MM->path() ], [ @path_eg ] ),
152 # static_lib() should look into that
153 # dynamic_bs() should look into that
154 # dynamic_lib() should look into that
158 my $clean = $Config{cc} =~ /^gcc/i ? 'dll.base dll.exp' : '*.pdb';
159 like( MM->clean(), qr/^clean ::\s+\Q-$(RM_F) $clean\E\s+$/m,
160 'clean() Makefile target' );
165 my $libperl = $Config{libperl} || 'libperl.a';
166 is( MM->perl_archive(), File::Spec->catfile('$(PERL_INC)', $libperl ),
167 'perl_archive() should respect libperl setting' );
172 my $mm_w32 = bless { BASEEXT => 'someext' }, 'ExtUtils::MM_Win32';
173 is( $mm_w32->export_list(), 'someext.def', 'export_list()' );
178 my $path = 'c:\\Program Files/SomeApp\\Progje.exe';
179 is( MM->canonpath( $path ), File::Spec->canonpath( $path ),
180 'canonpath() eq File::Spec->canonpath' );
185 my $script_name = 'mm_w32tmp';
188 skip( "Can't create temp file: $!", 4 )
189 unless open SCRIPT, "> $script_name";
190 print SCRIPT <<'EOSCRIPT';
194 skip( "Can't write to temp file: $!", 4 )
197 is( MM->perl_script( $script_name ),
198 "${script_name}$script_ext", "perl_script ($script_ext)" );
200 skip( "Can't rename temp file: $!", 3 )
201 unless rename $script_name, "${script_name}.pl";
203 is( MM->perl_script( $script_name ),
204 "${script_name}$script_ext", "perl_script ($script_ext)" );
206 skip( "Can't rename temp file: $!", 2 )
207 unless rename "${script_name}$script_ext", "${script_name}.bat";
208 $script_ext = '.bat';
209 is( MM->perl_script( $script_name ),
210 "${script_name}$script_ext", "perl_script ($script_ext)" );
212 skip( "Can't rename temp file: $!", 1 )
213 unless rename "${script_name}$script_ext", "${script_name}.noscript";
214 $script_ext = '.noscript';
216 isnt( MM->perl_script( $script_name ),
217 "${script_name}$script_ext",
218 "not a perl_script anymore ($script_ext)" );
219 is( MM->perl_script( $script_name ), '',
220 "perl_script ($script_ext) returns empty" );
222 unlink "${script_name}$script_ext" if -f "${script_name}$script_ext";
227 like( MM->pm_to_blib(),
228 qr/^pm_to_blib: \Q$(TO_INST_PM)\E.+\Q$(TOUCH) \E\$@\s+$/ms,
234 like( MM->test_via_harness( $^X, 'MM_Win32.t' ),
235 qr/^\t\Q$^X\E \-Mblib.+"use Test::Harness.+MM_Win32.t\n$/,
236 'test_via_harness()' );
241 my %attribs = ( MAXLEN => 255 );
242 like( MM->tool_autosplit( %attribs ),
243 qr/^\#\ Usage:\ \$\(AUTOSPLITFILE\)
244 \ FileToSplit\ AutoDirToSplitInto.+
245 AUTOSPLITFILE\ =\ \$\(PERL\)\
246 "\-I\$\(PERL_ARCHLIB\)"\ "\-I\$\(PERL_LIB\)".+
247 \$AutoSplit::Maxlen=$attribs{MAXLEN};
249 'tool_autosplit()' );
254 ( my $mm_w32 = bless { }, 'MM' )->init_others();
256 my $bin_sh = ( $Config{make} =~ /^dmake/i
257 ? "" : ($Config{sh} || 'cmd /c') . "\n" );
259 my $tools = join "\n", map "$_ = $mm_w32->{ $_ }"
260 => qw(CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL);
262 like( $mm_w32->tools_other(),
263 qr/^SHELL = \Q$bin_sh$tools/m,
267 # xs_o() should look into that
268 # top_targets() should look into that
273 HTMLLIBPODS => { 'MM_Win32.pm' => 1 },
274 HTMLSCRIPTPODS => { 'MM_Win32.t' => 1 },
277 my $pods = join " \\\n\t", keys %{$mm_w32->{HTMLLIBPODS}},
278 keys %{$mm_w32->{HTMLSCRIPTPODS}};
279 my $pod2html_exe = $mm_w32->catfile($Config{scriptdirexp},'pod2html');
280 $pod2html_exe = $mm_w32->perl_script( $pod2html_exe );
282 like( $mm_w32->htmlifypods(),
283 qr/^POD2HTML_EXE\ =\ \Q$pod2html_exe\E\n
285 htmlifypods\ :\ pure_all\ \Q$pods\E
287 'htmlifypods() Makefile target' );
292 my $mm_w32 = bless { NOECHO => '' }, 'MM';
293 like( $mm_w32->manifypods(),
294 qr/^\nmanifypods :\n\t\$\Q(NOOP)\E\n$/,
295 'manifypods() Makefile target' );
298 # dist_ci() should look into that
299 # dist_core() should look into that
303 my $pastru = "PASTHRU = " . ($Config{make} =~ /^nmake/i ? "-nologo" : "");
304 is( MM->pasthru(), $pastru, 'pasthru()' );
310 bless(\(my $scalar), $_[0]);
322 MM_Win32.t - Tests for ExtUtils::MM_Win32
326 - Methods to still be checked:
327 # static_lib() should look into that
328 # dynamic_bs() should look into that
329 # dynamic_lib() should look into that
330 # xs_o() should look into that
331 # top_targets() should look into that
332 # dist_ci() should look into that
333 # dist_core() should look into that
337 20011228 Abe Timmerman <abe@ztreet.demon.nl>