4 if( $ENV{PERL_CORE} ) {
18 if ($^O =~ /MSWin32/i) {
21 plan skip_all => 'This is not Win32';
30 require_ok( 'ExtUtils::MM_Win32' );
32 # Dummy MM object until we have a real MM init method.
37 MAKEFILE => 'Makefile',
40 MAKE => $Config{make},
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 my $had_pathext = exists $ENV{PATHEXT};
67 local $ENV{PATHEXT} = '.exe';
68 ok( ! $MM->maybe_command( 'not_a_command.com' ),
69 'not a maybe_command()' );
71 # Bug in Perl. local $ENV{FOO} won't delete the key afterward.
72 delete $ENV{PATHEXT} unless $had_pathext;
74 # file_name_is_absolute() [Does not support UNC-paths]
76 ok( $MM->file_name_is_absolute( 'C:/' ),
77 'file_name_is_absolute()' );
78 ok( ! $MM->file_name_is_absolute( 'some/path/' ),
79 'not file_name_is_absolute()' );
84 # Should be able to find running perl... $^X is OK on Win32
86 my $my_perl = $1 if $^X =~ /(.*)/; # are we in -T or -t?
87 my( $perl, $path ) = fileparse( $my_perl );
88 like( $MM->find_perl( $], [ $perl ], [ $path ], 0 ),
89 qr/^\Q$my_perl\E$/i, 'find_perl() finds this perl' );
92 # catdir() (calls MM_Win32->canonpath)
94 my @path_eg = qw( c: trick dir/now_OK );
96 is( $MM->catdir( @path_eg ),
97 'C:\\trick\\dir\\now_OK', 'catdir()' );
98 is( $MM->catdir( @path_eg ),
99 File::Spec->catdir( @path_eg ),
100 'catdir() eq File::Spec->catdir()' );
102 # catfile() (calls MM_Win32->catdir)
103 push @path_eg, 'file.ext';
105 is( $MM->catfile( @path_eg ),
106 'C:\\trick\\dir\\now_OK\\file.ext', 'catfile()' );
108 is( $MM->catfile( @path_eg ),
109 File::Spec->catfile( @path_eg ),
110 'catfile() eq File::Spec->catfile()' );
113 # init_others(): check if all keys are created and set?
114 # qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP TEST_F LD AR LDLOADLIBS DEV_NUL )
116 my $mm_w32 = bless( { BASEEXT => 'Foo' }, 'MM' );
117 $mm_w32->init_others();
118 my @keys = qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP
119 TEST_F LD AR LDLOADLIBS DEV_NULL );
120 for my $key ( @keys ) {
121 ok( $mm_w32->{ $key }, "init_others: $key" );
126 # XXX this test is probably useless now that we can call individual
127 # init_* methods and check the keys in $mm_w32 directly
130 NAME => 'TestMM_Win32',
132 PM => { 'MM_Win32.pm' => 1 },
135 # XXX Hack until we have a proper init method.
136 # Flesh out some necessary keys in the MM object.
137 @{$mm_w32}{qw(XS MAN1PODS MAN3PODS)} = ({}) x 3;
138 @{$mm_w32}{qw(C O_FILES H)} = ([]) x 3;
139 @{$mm_w32}{qw(PARENT_NAME)} = ('') x 3;
140 $mm_w32->{FULLEXT} = 'TestMM_Win32';
141 $mm_w32->{BASEEXT} = 'TestMM_Win32';
143 $mm_w32->init_VERSION;
144 $mm_w32->init_linker;
148 my $s_PM = join( " \\\n\t", sort keys %{$mm_w32->{PM}} );
149 my $k_PM = join( " \\\n\t", %{$mm_w32->{PM}} );
151 my $constants = $mm_w32->constants;
154 qr|^NAME \s* = \s* TestMM_Win32 \s* $|xms,
155 qr|^VERSION \s* = \s* 1\.00 \s* $|xms,
156 qr|^MAKEMAKER \s* = \s* \Q$INC{'ExtUtils/MakeMaker.pm'}\E \s* $|xms,
157 qr|^MM_VERSION \s* = \s* \Q$ExtUtils::MakeMaker::VERSION\E \s* $|xms,
158 qr|^TO_INST_PM \s* = \s* \Q$s_PM\E \s* $|xms,
159 qr|^PM_TO_BLIB \s* = \s* \Q$k_PM\E \s* $|xms,
162 like( $constants, $regex, 'constants() check' );
168 ok( eq_array( [ $MM->path() ], [ File::Spec->path ] ),
172 # static_lib() should look into that
173 # dynamic_bs() should look into that
174 # dynamic_lib() should look into that
178 my $libperl = File::Spec->catfile('$(PERL_INC)',
179 $Config{libperl} || 'libperl.a');
180 my $export = '$(BASEEXT).def';
184 is( $MM->{PERL_ARCHIVE}, $libperl, 'PERL_ARCHIVE' );
185 is( $MM->{PERL_ARCHIVE_AFTER}, $after, 'PERL_ARCHIVE_AFTER' );
186 is( $MM->{EXPORT_LIST}, $export, 'EXPORT_LIST' );
191 my $path = 'c:\\Program Files/SomeApp\\Progje.exe';
192 is( $MM->canonpath( $path ), File::Spec->canonpath( $path ),
193 'canonpath() eq File::Spec->canonpath' );
198 my $script_name = 'mm_w32tmp';
201 skip( "Can't create temp file: $!", 4 )
202 unless open SCRIPT, "> $script_name";
203 print SCRIPT <<'EOSCRIPT';
207 skip( "Can't write to temp file: $!", 4 )
210 is( $MM->perl_script( $script_name ),
211 "${script_name}$script_ext", "perl_script ($script_ext)" );
213 skip( "Can't rename temp file: $!", 3 )
214 unless rename $script_name, "${script_name}.pl";
216 is( $MM->perl_script( $script_name ),
217 "${script_name}$script_ext", "perl_script ($script_ext)" );
219 skip( "Can't rename temp file: $!", 2 )
220 unless rename "${script_name}$script_ext", "${script_name}.bat";
221 $script_ext = '.bat';
222 is( $MM->perl_script( $script_name ),
223 "${script_name}$script_ext", "perl_script ($script_ext)" );
225 skip( "Can't rename temp file: $!", 1 )
226 unless rename "${script_name}$script_ext", "${script_name}.noscript";
227 $script_ext = '.noscript';
229 isnt( $MM->perl_script( $script_name ),
230 "${script_name}$script_ext",
231 "not a perl_script anymore ($script_ext)" );
232 is( $MM->perl_script( $script_name ), undef,
233 "perl_script ($script_ext) returns empty" );
235 unlink "${script_name}$script_ext" if -f "${script_name}$script_ext";
238 # xs_o() should look into that
239 # top_targets() should look into that
241 # dist_ci() should look into that
242 # dist_core() should look into that
246 my $pastru = "PASTHRU = " . ($Config{make} =~ /^nmake/i ? "-nologo" : "");
247 is( $MM->pasthru(), $pastru, 'pasthru()' );
253 bless(\(my $scalar), $_[0]);
265 MM_Win32.t - Tests for ExtUtils::MM_Win32
269 - Methods to still be checked:
270 # static_lib() should look into that
271 # dynamic_bs() should look into that
272 # dynamic_lib() should look into that
273 # xs_o() should look into that
274 # top_targets() should look into that
275 # dist_ci() should look into that
276 # dist_core() should look into that
280 20011228 Abe Timmerman <abe@ztreet.demon.nl>