* tests/scripts/features/exec: Small cleanup

This commit is contained in:
Paul Smith 2021-03-15 01:15:18 -04:00
parent 52056d7b2c
commit 144f436c4b

View File

@ -3,13 +3,13 @@
use warnings; use warnings;
my $description = "Test that make can execute binaries as well as scripts with" my $description = "Test that make can execute binaries as well as scripts with"
." various shabangs and without a shebang"; ." various shabangs and without a shbang";
my $details = "The various shells that this test uses are the default" my $details = "The various shells that this test uses are the default"
." /bin/sh, \$SHELL and the perl interpreter that is" ." /bin/sh, \$SHELL and the perl interpreter that is"
." executing this test program. The shells are used for the value" ." executing this test program. The shells are used for the value"
." of SHELL inside the test makefile and also as a shebang in the" ." of SHELL inside the test makefile and also as a shbang in the"
." executed script. There is also a test which executes a script" ." executed script. There is also a test which executes a script"
." that has no shebang."; ." that has no shbang.";
# Only bother with this on UNIX systems # Only bother with this on UNIX systems
$port_type eq 'UNIX' or return -1; $port_type eq 'UNIX' or return -1;
@ -17,26 +17,26 @@ $port_type eq 'UNIX' or return -1;
my $usersh = $origENV{SHELL}; my $usersh = $origENV{SHELL};
my $answer = 'hello, world'; my $answer = 'hello, world';
my @shebangs = ('', '#!/bin/sh', "#!$usersh", "#!$perl_name"); my @shbangs = ('', '#!/bin/sh', "#!$usersh", "#!$perl_name");
my @shells = ('', 'SHELL=/bin/sh', "SHELL=$usersh"); my @shells = ('', 'SHELL=/bin/sh', "SHELL=$usersh");
# tests [0-11] # tests [0-11]
# Have a makefile with various SHELL= exec a shell program with varios # Have a makefile with various SHELL= exec a shell program with varios
# shebangs or without a shebang at all. # shbangs or without a shbang at all.
my $stem = './exec.cmd'; my $stem = './exec.cmd';
my $k = 0; my $k = 0;
for my $shebang (@shebangs) { for my $shbang (@shbangs) {
for my $shell (@shells) { for my $shell (@shells) {
my $cmd = $k ? "$stem.$k" : $stem; my $cmd = $k ? "$stem.$k" : $stem;
++$k; ++$k;
unlink $cmd; unlink $cmd;
open(CMD,"> $cmd"); open(CMD,"> $cmd");
print CMD "$shebang\n"; print CMD "$shbang\n";
print CMD "printf \"$answer\\n\";\n"; print CMD "printf \"$answer\\n\";\n";
close(CMD); close(CMD);
chmod 0700, $cmd; chmod 0700, $cmd;
run_make_test(q! run_make_test("# $shbang\n# $shell" . q!
all:; @$(CMD) all:; @$(CMD)
!, "$shell CMD=$cmd", "$answer\n"); !, "$shell CMD=$cmd", "$answer\n");