12 if ($^O =~ /MSWin32/i) {
15 plan skip_all => 'This is not Win32';
24 require_ok( 'ExtUtils::MM_Win32' );
26 # Dummy MM object until we have a real MM init method.
31 MAKEFILE => 'Makefile',
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 my $had_pathext = exists $ENV{PATHEXT};
61 local $ENV{PATHEXT} = '.exe';
62 ok( ! $MM->maybe_command( 'not_a_command.com' ),
63 'not a maybe_command()' );
65 # Bug in Perl. local $ENV{FOO} won't delete the key afterward.
66 delete $ENV{PATHEXT} unless $had_pathext;
68 # file_name_is_absolute() [Does not support UNC-paths]
70 ok( $MM->file_name_is_absolute( 'C:/' ),
71 'file_name_is_absolute()' );
72 ok( ! $MM->file_name_is_absolute( 'some/path/' ),
73 'not file_name_is_absolute()' );
78 # Should be able to find running perl... $^X is OK on Win32
80 my $my_perl = $1 if $^X =~ /(.*)/; # are we in -T or -t?
81 my( $perl, $path ) = fileparse( $my_perl );
82 like( $MM->find_perl( $], [ $perl ], [ $path ], 0 ),
83 qr/^\Q$my_perl\E$/i, 'find_perl() finds this perl' );
86 # catdir() (calls MM_Win32->canonpath)
88 my @path_eg = qw( c: trick dir/now_OK );
90 is( $MM->catdir( @path_eg ),
91 'C:\\trick\\dir\\now_OK', 'catdir()' );
92 is( $MM->catdir( @path_eg ),
93 File::Spec->catdir( @path_eg ),
94 'catdir() eq File::Spec->catdir()' );
96 # catfile() (calls MM_Win32->catdir)
97 push @path_eg, 'file.ext';
99 is( $MM->catfile( @path_eg ),
100 'C:\\trick\\dir\\now_OK\\file.ext', 'catfile()' );
102 is( $MM->catfile( @path_eg ),
103 File::Spec->catfile( @path_eg ),
104 'catfile() eq File::Spec->catfile()' );
107 # init_others(): check if all keys are created and set?
108 # qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP TEST_F LD AR LDLOADLIBS DEV_NUL )
110 my $mm_w32 = bless( { BASEEXT => 'Foo' }, 'MM' );
111 $mm_w32->init_others();
112 my @keys = qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP
113 TEST_F LD AR LDLOADLIBS DEV_NULL );
114 for my $key ( @keys ) {
115 ok( $mm_w32->{ $key }, "init_others: $key" );
120 # XXX this test is probably useless now that we can call individual
121 # init_* methods and check the keys in $mm_w32 directly
124 NAME => 'TestMM_Win32',
126 PM => { 'MM_Win32.pm' => 1 },
129 # XXX Hack until we have a proper init method.
130 # Flesh out some necessary keys in the MM object.
131 @{$mm_w32}{qw(XS MAN1PODS MAN3PODS)} = ({}) x 3;
132 @{$mm_w32}{qw(C O_FILES H)} = ([]) x 3;
133 @{$mm_w32}{qw(PARENT_NAME)} = ('') x 3;
134 $mm_w32->{FULLEXT} = 'TestMM_Win32';
135 $mm_w32->{BASEEXT} = 'TestMM_Win32';
137 $mm_w32->init_VERSION;
138 $mm_w32->init_linker;
142 my $s_PM = join( " \\\n\t", sort keys %{$mm_w32->{PM}} );
143 my $k_PM = join( " \\\n\t", %{$mm_w32->{PM}} );
145 my $constants = $mm_w32->constants;
148 qr|^NAME \s* = \s* TestMM_Win32 \s* $|xms,
149 qr|^VERSION \s* = \s* 1\.00 \s* $|xms,
150 qr|^MAKEMAKER \s* = \s* \Q$INC{'ExtUtils/MakeMaker.pm'}\E \s* $|xms,
151 qr|^MM_VERSION \s* = \s* \Q$ExtUtils::MakeMaker::VERSION\E \s* $|xms,
152 qr|^TO_INST_PM \s* = \s* \Q$s_PM\E \s* $|xms,
153 qr|^PM_TO_BLIB \s* = \s* \Q$k_PM\E \s* $|xms,
156 like( $constants, $regex, 'constants() check' );
162 ok( eq_array( [ $MM->path() ], [ File::Spec->path ] ),
166 # static_lib() should look into that
167 # dynamic_bs() should look into that
168 # dynamic_lib() should look into that
172 my $libperl = File::Spec->catfile('$(PERL_INC)',
173 $Config{libperl} || 'libperl.a');
174 my $export = '$(BASEEXT).def';
178 is( $MM->{PERL_ARCHIVE}, $libperl, 'PERL_ARCHIVE' );
179 is( $MM->{PERL_ARCHIVE_AFTER}, $after, 'PERL_ARCHIVE_AFTER' );
180 is( $MM->{EXPORT_LIST}, $export, 'EXPORT_LIST' );
185 my $path = 'c:\\Program Files/SomeApp\\Progje.exe';
186 is( $MM->canonpath( $path ), File::Spec->canonpath( $path ),
187 'canonpath() eq File::Spec->canonpath' );
192 my $script_name = 'mm_w32tmp';
195 skip( "Can't create temp file: $!", 4 )
196 unless open SCRIPT, "> $script_name";
197 print SCRIPT <<'EOSCRIPT';
201 skip( "Can't write to temp file: $!", 4 )
204 is( $MM->perl_script( $script_name ),
205 "${script_name}$script_ext", "perl_script ($script_ext)" );
207 skip( "Can't rename temp file: $!", 3 )
208 unless rename $script_name, "${script_name}.pl";
210 is( $MM->perl_script( $script_name ),
211 "${script_name}$script_ext", "perl_script ($script_ext)" );
213 skip( "Can't rename temp file: $!", 2 )
214 unless rename "${script_name}$script_ext", "${script_name}.bat";
215 $script_ext = '.bat';
216 is( $MM->perl_script( $script_name ),
217 "${script_name}$script_ext", "perl_script ($script_ext)" );
219 skip( "Can't rename temp file: $!", 1 )
220 unless rename "${script_name}$script_ext", "${script_name}.noscript";
221 $script_ext = '.noscript';
223 isnt( $MM->perl_script( $script_name ),
224 "${script_name}$script_ext",
225 "not a perl_script anymore ($script_ext)" );
226 is( $MM->perl_script( $script_name ), undef,
227 "perl_script ($script_ext) returns empty" );
229 unlink "${script_name}$script_ext" if -f "${script_name}$script_ext";
233 # Check for literal nmake
235 skip("Not using 'nmake'", 2) unless $Config{make} eq 'nmake';
236 ok( $MM->is_make_type('nmake'), '->is_make_type(nmake) true' );
237 ok( ! $MM->is_make_type('dmake'), '->is_make_type(dmake) false' );
240 # Check for literal nmake
242 skip("Not using /nmake/", 2) unless $Config{make} =~ /nmake/;
243 ok( $MM->is_make_type('nmake'), '->is_make_type(nmake) true' );
244 ok( ! $MM->is_make_type('dmake'), '->is_make_type(dmake) false' );
247 # Check for literal dmake
249 skip("Not using 'dmake'", 2) unless $Config{make} eq 'dmake';
250 ok( $MM->is_make_type('dmake'), '->is_make_type(dmake) true' );
251 ok( ! $MM->is_make_type('nmake'), '->is_make_type(nmake) false' );
254 # Check for literal dmake
256 skip("Not using /dmake/", 2) unless $Config{make} =~ /dmake/;
257 ok( $MM->is_make_type('dmake'), '->is_make_type(dmake) true' );
258 ok( ! $MM->is_make_type('nmake'), '->is_make_type(nmake) false' );
263 # xs_o() should look into that
264 # top_targets() should look into that
266 # dist_ci() should look into that
267 # dist_core() should look into that
271 my $pastru = "PASTHRU = " . ($Config{make} =~ /^nmake/i ? "-nologo" : "");
272 is( $MM->pasthru(), $pastru, 'pasthru()' );
278 bless(\(my $scalar), $_[0]);
290 MM_Win32.t - Tests for ExtUtils::MM_Win32
294 - Methods to still be checked:
295 # static_lib() should look into that
296 # dynamic_bs() should look into that
297 # dynamic_lib() should look into that
298 # xs_o() should look into that
299 # top_targets() should look into that
300 # dist_ci() should look into that
301 # dist_core() should look into that
305 20011228 Abe Timmerman <abe@ztreet.demon.nl>