4 if( $ENV{PERL_CORE} ) {
14 if ($^O =~ /MSWin32/i) {
17 plan skip_all => 'This is not Win32';
24 use ExtUtils::MakeMaker;
26 require_ok( 'ExtUtils::MM_Win32' );
28 # test import of $Verbose and &neatvalue
29 can_ok( 'MM', 'neatvalue' );
30 () = $ExtUtils::MM_Win32::Verbose;
31 () = $ExtUtils::MakeMaker::Verbose;
32 is( $ExtUtils::MM_Win32::Verbose, $ExtUtils::MakeMaker::Verbose,
33 'ExtUtils::MM_Win32 should import $Verbose from ExtUtils::MakeMaker' );
36 ##### Start new tests at the top of MM_Win32
38 # replace_manpage_separator() => tr|/|.|s ?
40 my $man = 'a/path/to//something';
41 ( my $replaced = $man ) =~ tr|/|.|s;
42 is( MM->replace_manpage_separator( $man ),
43 $replaced, 'replace_manpage_separator()' );
48 skip( '$ENV{COMSPEC} not set', 2 )
49 unless $ENV{COMSPEC} =~ m!((?:[a-z]:)?[^|<>]+)!i;
51 is( MM->maybe_command( $comspec ),
52 $comspec, 'COMSPEC is a maybe_command()' );
53 ( my $comspec2 = $comspec ) =~ s|\..{3}$||;
54 like( MM->maybe_command( $comspec2 ),
56 'maybe_command() without extension' );
59 local $ENV{PATHEXT} = '.exe';
60 ok( ! MM->maybe_command( 'not_a_command.com' ),
61 'not a maybe_command()' );
64 # file_name_is_absolute() [Does not support UNC-paths]
66 ok( MM->file_name_is_absolute( 'C:/' ),
67 'file_name_is_absolute()' );
68 ok( ! MM->file_name_is_absolute( 'some/path/' ),
69 'not file_name_is_absolute()' );
74 # Should be able to find running perl... $^X is OK on Win32
76 my $my_perl = $1 if $^X =~ /(.*)/; # are we in -T or -t?
77 my( $perl, $path ) = fileparse( $my_perl );
78 like( MM->find_perl( $], [ $perl ], [ $path ] ),
79 qr/^\Q$my_perl\E$/i, 'find_perl() finds this perl' );
82 # catdir() (calls MM_Win32->canonpath)
84 my @path_eg = qw( c: trick dir/now_OK );
86 is( MM->catdir( @path_eg ),
87 'C:\\trick\\dir\\now_OK', 'catdir()' );
88 is( MM->catdir( @path_eg ),
89 File::Spec->catdir( @path_eg ),
90 'catdir() eq File::Spec->catdir()' );
92 # catfile() (calls MM_Win32->catdir)
93 push @path_eg, 'file.ext';
95 is( MM->catfile( @path_eg ),
96 'C:\\trick\\dir\\now_OK\\file.ext', 'catfile()' );
98 is( MM->catfile( @path_eg ),
99 File::Spec->catfile( @path_eg ),
100 'catfile() eq File::Spec->catfile()' );
103 # init_others(): check if all keys are created and set?
104 # qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP TEST_F LD AR LDLOADLIBS DEV_NUL )
106 my $mm_w32 = bless( {}, 'MM' );
107 $mm_w32->init_others();
108 my @keys = qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP
109 TEST_F LD AR LDLOADLIBS DEV_NULL );
110 for my $key ( @keys ) {
111 ok( $mm_w32->{ $key }, "init_others: $key" );
118 NAME => 'TestMM_Win32',
120 VERSION_FROM => 'TestMM_Win32',
121 PM => { 'MM_Win32.pm' => 1 },
124 # XXX Hack until we have a proper init method.
125 # Flesh out some necessary keys in the MM object.
126 foreach my $key (qw(XS C O_FILES H HTMLLIBPODS HTMLSCRIPTPODS
127 MAN1PODS MAN3PODS PARENT_NAME)) {
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 ), undef,
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" );
258 $bin_sh = "SHELL = $bin_sh" if $bin_sh;
260 my $tools = join "\n", map "$_ = $mm_w32->{ $_ }"
261 => qw(CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL);
263 like( $mm_w32->tools_other(),
264 qr/^\Q$bin_sh$tools/m,
268 # xs_o() should look into that
269 # top_targets() should look into that
274 HTMLLIBPODS => { 'MM_Win32.pm' => 1 },
275 HTMLSCRIPTPODS => { 'MM_Win32.t' => 1 },
278 my $pods = join " \\\n\t", keys %{$mm_w32->{HTMLLIBPODS}},
279 keys %{$mm_w32->{HTMLSCRIPTPODS}};
281 my $pod2html_exe = $mm_w32->catfile($Config{scriptdirexp},'pod2html');
282 unless ( $pod2html_exe = $mm_w32->perl_script( $pod2html_exe ) ) {
283 $pod2html_exe = '-S pod2html';
286 like( $mm_w32->htmlifypods(),
287 qr/^POD2HTML_EXE\ =\ \Q$pod2html_exe\E\n
289 htmlifypods\ :\ pure_all\ \Q$pods\E
291 'htmlifypods() Makefile target' );
296 my $mm_w32 = bless { NOECHO => '' }, 'MM';
297 like( $mm_w32->manifypods(),
298 qr/^\nmanifypods :\n\t\$\Q(NOOP)\E\n$/,
299 'manifypods() Makefile target' );
302 # dist_ci() should look into that
303 # dist_core() should look into that
307 my $pastru = "PASTHRU = " . ($Config{make} =~ /^nmake/i ? "-nologo" : "");
308 is( MM->pasthru(), $pastru, 'pasthru()' );
314 bless(\(my $scalar), $_[0]);
326 MM_Win32.t - Tests for ExtUtils::MM_Win32
330 - Methods to still be checked:
331 # static_lib() should look into that
332 # dynamic_bs() should look into that
333 # dynamic_lib() should look into that
334 # xs_o() should look into that
335 # top_targets() should look into that
336 # dist_ci() should look into that
337 # dist_core() should look into that
341 20011228 Abe Timmerman <abe@ztreet.demon.nl>