12 if ($^O =~ /NetWare/i) {
15 plan skip_all => 'This is not NW5';
24 require_ok( 'ExtUtils::MM_NW5' );
26 # Dummy MM object until we have a real MM init method.
31 MAKEFILE => 'Makefile',
37 # replace_manpage_separator() => tr|/|.|s ?
39 my $man = 'a/path/to//something';
40 ( my $replaced = $man ) =~ tr|/|.|s;
41 is( $MM->replace_manpage_separator( $man ),
42 $replaced, 'replace_manpage_separator()' );
47 skip( '$ENV{COMSPEC} not set', 2 )
48 unless $ENV{COMSPEC} =~ m!((?:[a-z]:)?[^|<>]+)!i;
50 is( $MM->maybe_command( $comspec ),
51 $comspec, 'COMSPEC is a maybe_command()' );
52 ( my $comspec2 = $comspec ) =~ s|\..{3}$||;
53 like( $MM->maybe_command( $comspec2 ),
55 'maybe_command() without extension' );
58 my $had_pathext = exists $ENV{PATHEXT};
60 local $ENV{PATHEXT} = '.exe';
61 ok( ! $MM->maybe_command( 'not_a_command.com' ),
62 'not a maybe_command()' );
64 # Bug in Perl. local $ENV{FOO} won't delete the key afterward.
65 delete $ENV{PATHEXT} unless $had_pathext;
67 # file_name_is_absolute() [Does not support UNC-paths]
69 ok( $MM->file_name_is_absolute( 'SYS:/' ),
70 'file_name_is_absolute()' );
71 ok( ! $MM->file_name_is_absolute( 'some/path/' ),
72 'not file_name_is_absolute()' );
77 # Should be able to find running perl... $^X is OK on NW5
79 my $my_perl = $1 if $^X =~ /(.*)/; # are we in -T or -t?
80 my( $perl, $path ) = fileparse( $my_perl );
81 like( $MM->find_perl( $], [ $perl ], [ $path ] ),
82 qr/^\Q$my_perl\E$/i, 'find_perl() finds this perl' );
85 # catdir() (calls MM_NW5->canonpath)
87 my @path_eg = qw( SYS trick dir/now_OK );
89 is( $MM->catdir( @path_eg ),
90 'SYS\\trick\\dir\\now_OK', 'catdir()' );
91 is( $MM->catdir( @path_eg ),
92 File::Spec->catdir( @path_eg ),
93 'catdir() eq File::Spec->catdir()' );
95 # catfile() (calls MM_NW5->catdir)
96 push @path_eg, 'file.ext';
98 is( $MM->catfile( @path_eg ),
99 'SYS\\trick\\dir\\now_OK\\file.ext', 'catfile()' );
101 is( $MM->catfile( @path_eg ),
102 File::Spec->catfile( @path_eg ),
103 'catfile() eq File::Spec->catfile()' );
106 # init_others(): check if all keys are created and set?
107 # qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP TEST_F LD AR LDLOADLIBS DEV_NUL )
109 my $mm_w32 = bless( {}, 'MM' );
110 $mm_w32->init_others();
111 my @keys = qw( TOUCH CHMOD CP RM_F RM_RF MV NOOP
112 TEST_F LD AR LDLOADLIBS DEV_NULL );
113 for my $key ( @keys ) {
114 ok( $mm_w32->{ $key }, "init_others: $key" );
121 NAME => 'TestMM_NW5',
123 VERSION_FROM => 'TestMM_NW5',
124 PM => { 'MM_NW5.pm' => 1 },
127 # XXX Hack until we have a proper init method.
128 # Flesh out some necessary keys in the MM object.
129 foreach my $key (qw(XS C O_FILES H HTMLLIBPODS HTMLSCRIPTPODS
130 MAN1PODS MAN3PODS PARENT_NAME)) {
131 $mm_w32->{$key} = '';
133 my $s_PM = join( " \\\n\t", sort keys %{$mm_w32->{PM}} );
134 my $k_PM = join( " \\\n\t", %{$mm_w32->{PM}} );
136 like( $mm_w32->constants(),
137 qr|^NAME\ =\ TestMM_NW5\s+VERSION\ =\ 1\.00.+
138 MAKEMAKER\ =\ \Q$INC{'ExtUtils/MakeMaker.pm'}\E\s+
139 MM_VERSION\ =\ \Q$ExtUtils::MakeMaker::VERSION\E.+
140 VERSION_FROM\ =\ TestMM_NW5.+
141 TO_INST_PM\ =\ \Q$s_PM\E\s+
142 PM_TO_BLIB\ =\ \Q$k_PM\E
143 |xs, 'constants()' );
148 my $had_path = exists $ENV{PATH};
150 my @path_eg = ( qw( . .. ), 'SYS:\\Program Files' );
151 local $ENV{PATH} = join ';', @path_eg;
152 ok( eq_array( [ $MM->path() ], [ @path_eg ] ),
155 # Bug in Perl. local $ENV{FOO} will not delete key afterwards.
156 delete $ENV{PATH} unless $had_path;
158 # static_lib() should look into that
159 # dynamic_bs() should look into that
160 # dynamic_lib() should look into that
164 my $clean = $Config{cc} =~ /^gcc/i ? 'dll.base dll.exp' : '*.pdb';
165 like( $MM->clean(), qr/^clean ::\s+\Q-$(RM_F) $clean\E\s+$/m,
166 'clean() Makefile target' );
172 my $libperl = $Config{libperl} || 'libperl.a';
173 my $export = '$(BASEEXT).def';
177 is( $MM->{PERL_ARCHIVE}, $libperl, 'PERL_ARCHIVE' );
178 is( $MM->{PERL_ARCHIVE_AFTER}, $after, 'PERL_ARCHIVE_AFTER' );
179 is( $MM->{EXPORT_LIST}, $export, 'EXPORT_LIST' );
185 my $path = 'SYS:/TEMP';
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";
234 like( $MM->pm_to_blib(),
235 qr/^pm_to_blib: \Q$(TO_INST_PM)\E.+\Q$(TOUCH) \E\$@\s+$/ms,
241 my %attribs = ( MAXLEN => 255 );
242 like( $MM->tool_autosplit( %attribs ),
243 qr/^\#\ Usage:\ \$\(AUTOSPLITFILE\)
244 \ FileToSplit\ AutoDirToSplitInto.+
245 AUTOSPLITFILE\ =\ \$\(PERLRUN\)\ .+
246 \$AutoSplit::Maxlen=$attribs{MAXLEN};
248 'tool_autosplit()' );
252 # xs_o() should look into that
253 # top_targets() should look into that
255 # dist_ci() should look into that
256 # dist_core() should look into that
260 my $pastru = "PASTHRU = " . ($Config{make} =~ /^nmake/i ? "-nologo" : "");
261 is( $MM->pasthru(), $pastru, 'pasthru()' );
267 bless(\(my $scalar), $_[0]);
279 MM_NW5.t - Tests for ExtUtils::MM_NW5
283 - Methods to still be checked:
284 # static_lib() should look into that
285 # dynamic_bs() should look into that
286 # dynamic_lib() should look into that
287 # xs_o() should look into that
288 # top_targets() should look into that
289 # dist_ci() should look into that
290 # dist_core() should look into that
294 20011228 Abe Timmerman <abe@ztreet.demon.nl>