Skip to content

Commit 438d0ec

Browse files
committed
Make macros portably in basic.t
Not every make utility can take arbitrary command parameters and turn them into make macros, but there is already a utility function to build a make command with whatever it needs to send macros on the command line, so use it.
1 parent b31ca34 commit 438d0ec

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

t/basic.t

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,11 @@ $mtext =~ s/^(\s*PERL\s*=.*)$/$1 -Iinc/m;
183183
write_file($makefile, $mtext);
184184

185185
sub check_dummy_inst {
186-
my ($loc, $install_args, $label, $skipsubdir) = @_;
186+
my ($loc, $label, $skipsubdir) = (shift, shift, shift);
187187
my %files;
188188
SKIP: {
189-
my $install_out = run("$make install NOECHO= $install_args");
189+
my $run_cmd = make_macro($make, 'install', 'NOECHO' => '', @_);
190+
my $install_out = run($run_cmd);
190191
is( $?, 0, "install $label" ) || diag $install_out;
191192
like( $install_out, qr/^Installing /m, "/Installing/ $label" );
192193
ok( -r $loc, "$label install dir created" )
@@ -209,17 +210,17 @@ sub check_dummy_inst {
209210
\%files;
210211
}
211212

212-
check_dummy_inst($DUMMYINST, '', 'Module::Install style');
213+
check_dummy_inst($DUMMYINST, 'Module::Install style');
213214

214215
SKIP: {
215216
skip 'VMS install targets do not preserve $(PREFIX)', 8 if $Is_VMS;
216-
check_dummy_inst('elsewhere', "PREFIX=elsewhere", 'with PREFIX');
217+
check_dummy_inst('elsewhere', 'with PREFIX', 0, 'PREFIX' => 'elsewhere');
217218
rmtree('elsewhere');
218219
}
219220

220221
SKIP: {
221222
skip 'VMS install targets do not preserve $(DESTDIR)', 10 if $Is_VMS;
222-
my $files = check_dummy_inst('other', 'PREFIX= DESTDIR=other', 'with DESTDIR');
223+
my $files = check_dummy_inst('other', 'with DESTDIR', 0, 'PREFIX' => '', 'DESTDIR' => 'other');
223224
eval {
224225
unlike slurp($files->{'perllocal.pod'}), qr/other/, 'DESTDIR should not appear in perllocal'; 1
225226
} or fail "error in slurp: $@";
@@ -239,7 +240,7 @@ SKIP: {
239240

240241
SKIP: {
241242
skip 'VMS install targets do not preserve $(PREFIX)', 9 if $Is_VMS;
242-
check_dummy_inst('other/elsewhere', 'PREFIX=elsewhere DESTDIR=other/', 'PREFIX override and DESTDIR');
243+
check_dummy_inst('other/elsewhere', 'PREFIX override and DESTDIR', 0, 'PREFIX' => 'elsewhere', 'DESTDIR' => 'other/');
243244
ok( !-d 'elsewhere', ' install dir not created' );
244245
rmtree('other');
245246
}
@@ -460,13 +461,13 @@ write_file($file, $text);
460461
# now do with "Liar" subdir still there
461462
rmtree $DUMMYINST; # so no false positive from before
462463
@mpl_out = run(qq{$perl Makefile.PL "PREFIX=$DUMMYINST"});
463-
check_dummy_inst($DUMMYINST, '', "with PREFIX=$DUMMYINST");
464+
check_dummy_inst($DUMMYINST, "with PREFIX=$DUMMYINST");
464465
# now clean, delete "Liar" subdir, do again
465466
$realclean_out = run("$make realclean");
466467
rmtree 'Liar';
467468
rmtree $DUMMYINST; # so no false positive from before
468469
@mpl_out = run(qq{$perl Makefile.PL "PREFIX=$DUMMYINST"});
469-
check_dummy_inst($DUMMYINST, '', "with PREFIX=$DUMMYINST minus subdir", 1);
470+
check_dummy_inst($DUMMYINST, "with PREFIX=$DUMMYINST minus subdir", 1);
470471
write_file($file, $preserve_MPL); # restore Makefile.PL
471472
$realclean_out = run("$make realclean");
472473
rmtree 'Liar';
@@ -477,7 +478,8 @@ $text = $preserve_MPL;
477478
ok(($text =~ s:\);: PM_FILTER => '\$(ABSPERLRUN) -ne "print unless /^#/"',\n$&:), 'successful M.PL edit');
478479
write_file($file, $text);
479480
@mpl_out = run(qq{$perl Makefile.PL});
480-
$test_out = run("$make test NOECHO=");
481+
my $run_cmd = make_macro($make, 'test', 'NOECHO' => '');
482+
$test_out = run($run_cmd);
481483
like( $test_out, qr/All tests successful/, 'make test' );
482484
is( $?, 0, ' exited normally' ) ||
483485
diag $test_out;

0 commit comments

Comments
 (0)