11 if ($^O =~ /MSWin32/i) {
14 plan skip_all => 'This is not Win32';
22 # Does this mimic ExtUtils::MakeMaker ok?
26 ExtUtils::Liblist::Kid
29 # MM package faked up by messy MI entanglement
34 require_ok( 'ExtUtils::MM_Win32' );
36 # test import of $Verbose and &neatvalue
37 can_ok( 'MM', 'neatvalue' );
38 is( $ExtUtils::MM_Win32::Verbose, $ExtUtils::MakeMaker::Verbose,
39 'ExtUtils::MM_Win32 should import $Verbose from ExtUtils::MakeMaker' );
42 ##### Start new tests at the top of MM_Win32
44 # replace_manpage_separator() => tr|/|.|s ?
46 my $man = 'a/path/to//something';
47 ( my $replaced = $man ) =~ tr|/|.|s;
48 is( MM->replace_manpage_separator( $man ),
49 $replaced, 'replace_manpage_separator()' );
54 skip( '$ENV{COMSPEC} not set', 2 )
55 unless $ENV{COMSPEC} =~ m!((?:[a-z]:)?[^|<>]+)!i;
57 is( MM->maybe_command( $comspec ),
58 $comspec, 'COMSPEC is a maybe_command()' );
59 ( my $comspec2 = $comspec ) =~ s|\..{3}$||;
60 like( MM->maybe_command( $comspec2 ),
62 'maybe_command() without extension' );
65 local $ENV{PATHEXT} = '.exe';
66 ok( ! MM->maybe_command( 'not_a_command.com' ),
67 'not a maybe_command()' );
70 # file_name_is_absolute() [Does not support UNC-paths]
72 ok( MM->file_name_is_absolute( 'C:/' ),
73 'file_name_is_absolute()' );
74 ok( ! MM->file_name_is_absolute( 'some/path/' ),
75 'not file_name_is_absolute()' );
80 # Should be able to find running perl... $^X is OK on Win32
82 my $my_perl = $1 if $^X =~ /(.*)/; # are we in -T or -t?
83 my( $perl, $path ) = fileparse( $my_perl );
84 like( MM->find_perl( $], [ $perl ], [ $path ] ),
85 qr/^\Q$my_perl\E$/i, 'find_perl() finds this perl' );
88 # catdir() (calls MM_Win32->canonpath)
90 my @path_eg = qw( c: trick dir/now_OK );
92 is( MM->catdir( @path_eg ),
93 'C:\\trick\\dir\\now_OK', 'catdir()' );
94 is( MM->catdir( @path_eg ),
95 File::Spec->catdir( @path_eg ),
96 'catdir() eq File::Spec->catdir()' );
98 # catfile() (calls MM_Win32->catdir)
99 push @path_eg, 'file.ext';
101 is( MM->catfile( @path_eg ),
102 'C:\\trick\\dir\\now_OK\\file.ext', 'catfile()' );
104 is( MM->catfile( @path_eg ),
105 File::Spec->catfile( @path_eg ),
106 'catfile() eq File::Spec->catfile()' );
109 # init_others(): check if all keys are created and set?
110 # qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP TEST_F LD AR LDLOADLIBS DEV_NUL )
112 my $mm_w32 = bless( {}, 'MM' );
113 $mm_w32->init_others();
114 my @keys = qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP
115 TEST_F LD AR LDLOADLIBS DEV_NULL );
116 for my $key ( @keys ) {
117 ok( $mm_w32->{ $key }, "init_others: $key" );
124 NAME => 'TestMM_Win32',
126 VERSION_FROM => 'TestMM_Win32',
127 PM => { 'MM_Win32.pm' => 1 },
129 my $s_PM = join( " \\\n\t", sort keys %{$mm_w32->{PM}} );
130 my $k_PM = join( " \\\n\t", %{$mm_w32->{PM}} );
132 like( $mm_w32->constants(),
133 qr/^NAME\ =\ TestMM_Win32\s+VERSION\ =\ 1\.00.+
134 MAKEMAKER\ =\ $INC{'ExtUtils\MakeMaker.pm'}\s+
135 MM_VERSION\ =\ $ExtUtils::MakeMaker::VERSION.+
136 VERSION_FROM\ =\ TestMM_Win32.+
137 TO_INST_PM\ =\ \Q$s_PM\E\s+
138 PM_TO_BLIB\ =\ \Q$k_PM\E
139 /xs, 'constants()' );
145 my @path_eg = ( qw( . .. ), 'C:\\Program Files' );
146 local $ENV{PATH} = join ';', @path_eg;
147 ok( eq_array( [ MM->path() ], [ @path_eg ] ),
151 # static_lib() should look into that
152 # dynamic_bs() should look into that
153 # dynamic_lib() should look into that
157 my $clean = $Config{cc} =~ /^gcc/i ? 'dll.base dll.exp' : '*.pdb';
158 like( MM->clean(), qr/^clean ::\s+\Q-$(RM_F) $clean\E\s+$/m,
159 'clean() Makefile target' );
164 my $libperl = $Config{libperl} || 'libperl.a';
165 is( MM->perl_archive(), File::Spec->catfile('$(PERL_INC)', $libperl ),
166 'perl_archive() should respect libperl setting' );
171 my $mm_w32 = bless { BASEEXT => 'someext' }, 'ExtUtils::MM_Win32';
172 is( $mm_w32->export_list(), 'someext.def', 'export_list()' );
177 my $path = 'c:\\Program Files/SomeApp\\Progje.exe';
178 is( MM->canonpath( $path ), File::Spec->canonpath( $path ),
179 'canonpath() eq File::Spec->canonpath' );
184 my $script_name = 'mm_w32tmp';
187 skip( "Can't create temp file: $!", 4 )
188 unless open SCRIPT, "> $script_name";
189 print SCRIPT <<'EOSCRIPT';
193 skip( "Can't write to temp file: $!", 4 )
196 is( MM->perl_script( $script_name ),
197 "${script_name}$script_ext", "perl_script ($script_ext)" );
199 skip( "Can't rename temp file: $!", 3 )
200 unless rename $script_name, "${script_name}.pl";
202 is( MM->perl_script( $script_name ),
203 "${script_name}$script_ext", "perl_script ($script_ext)" );
205 skip( "Can't rename temp file: $!", 2 )
206 unless rename "${script_name}$script_ext", "${script_name}.bat";
207 $script_ext = '.bat';
208 is( MM->perl_script( $script_name ),
209 "${script_name}$script_ext", "perl_script ($script_ext)" );
211 skip( "Can't rename temp file: $!", 1 )
212 unless rename "${script_name}$script_ext", "${script_name}.noscript";
213 $script_ext = '.noscript';
215 isnt( MM->perl_script( $script_name ),
216 "${script_name}$script_ext",
217 "not a perl_script anymore ($script_ext)" );
218 is( MM->perl_script( $script_name ), '',
219 "perl_script ($script_ext) returns empty" );
221 unlink "${script_name}$script_ext" if -f "${script_name}$script_ext";
226 like( MM->pm_to_blib(),
227 qr/^pm_to_blib: \Q$(TO_INST_PM)\E.+\Q$(TOUCH) \E\$@\s+$/ms,
233 like( MM->test_via_harness( $^X, 'MM_Win32.t' ),
234 qr/^\t\Q$^X\E \-Mblib.+"use Test::Harness.+MM_Win32.t\n$/,
235 'test_via_harness()' );
240 my %attribs = ( MAXLEN => 255 );
241 like( MM->tool_autosplit( %attribs ),
242 qr/^\#\ Usage:\ \$\(AUTOSPLITFILE\)
243 \ FileToSplit\ AutoDirToSplitInto.+
244 AUTOSPLITFILE\ =\ \$\(PERL\)\
245 "\-I\$\(PERL_ARCHLIB\)"\ "\-I\$\(PERL_LIB\)".+
246 \$AutoSplit::Maxlen=$attribs{MAXLEN};
248 'tool_autosplit()' );
253 ( my $mm_w32 = bless { }, 'MM' )->init_others();
255 my $bin_sh = ( $Config{make} =~ /^dmake/i
256 ? "" : ($Config{sh} || 'cmd /c') . "\n" );
258 my $tools = join "\n", map "$_ = $mm_w32->{ $_ }"
259 => qw(CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL);
261 like( $mm_w32->tools_other(),
262 qr/^SHELL = \Q$bin_sh$tools/m,
266 # xs_o() should look into that
267 # top_targets() should look into that
272 HTMLLIBPODS => { 'MM_Win32.pm' => 1 },
273 HTMLSCRIPTPODS => { 'MM_Win32.t' => 1 },
276 my $pods = join " \\\n\t", keys %{$mm_w32->{HTMLLIBPODS}},
277 keys %{$mm_w32->{HTMLSCRIPTPODS}};
278 my $pod2html_exe = $mm_w32->catfile($Config{scriptdirexp},'pod2html');
279 $pod2html_exe = $mm_w32->perl_script( $pod2html_exe );
281 like( $mm_w32->htmlifypods(),
282 qr/^POD2HTML_EXE\ =\ \Q$pod2html_exe\E\n
284 htmlifypods\ :\ pure_all\ \Q$pods\E
286 'htmlifypods() Makefile target' );
291 my $mm_w32 = bless { NOECHO => '' }, 'MM';
292 like( $mm_w32->manifypods(),
293 qr/^\nmanifypods :\n\t\$\Q(NOOP)\E\n$/,
294 'manifypods() Makefile target' );
297 # dist_ci() should look into that
298 # dist_core() should look into that
302 my $pastru = "PASTHRU = " . ($Config{make} =~ /^nmake/i ? "-nologo" : "");
303 is( MM->pasthru(), $pastru, 'pasthru()' );
309 bless(\(my $scalar), $_[0]);
321 MM_Win32.t - Tests for ExtUtils::MM_Win32
325 - Methods to still be checked:
326 # static_lib() should look into that
327 # dynamic_bs() should look into that
328 # dynamic_lib() should look into that
329 # xs_o() should look into that
330 # top_targets() should look into that
331 # dist_ci() should look into that
332 # dist_core() should look into that
336 20011228 Abe Timmerman <abe@ztreet.demon.nl>