make/tests/scripts/targets/ONESHELL
Paul Smith 11444fb001 [SV 62654] Support GNU Make on z/OS
Original patches provided by Igor Todorovski <itodorov@ca.ibm.com>
Reworked by Paul Smith <psmith@gnu.org>.
Thanks to IBM for providing a test system.

* NEWS: Announce support.
* AUTHORS: Ditto.
* README.zOS: Provide details on building GNU Make on z/OS.
* build.sh (get_mk_var): z/OS sh has a strange bug which causes it to
generate extra lines of output: rework the function to print output
as we compute it instead of collecting it into a variable, which
works around this bug.
* src/makeint.h: Declare MK_OS_ZOS if we're building for z/OS.
* src/arscan.c: Don't include <ar.h> on z/OS.
* src/job.c: We can't change environ in ASCII mode on z/OS.
* src/main.c: Ditto.  Also we can't use pselect() on z/OS.
* src/posixos.c: pselect() seems to hang on z/OS: don't use it.
* tests/run_make_tests.pl: Handle different exit codes on z/OS.
* tests/test_driver.pl: Preserve some special z/OS env.vars.
Add special checks to output comparisons when on z/OS.
* tests/scripts/features/archives: Don't validate names.  Don't
try to compile empty files as IBM compilers complain.
* tests/scripts/features/shell_assignment: Fix octal value of #.
* tests/scripts/features/temp_stdin: Don't print "term".
* tests/scripts/functions/shell: Handle shell exit codes.
* tests/scripts/targets/ONESHELL: Ditto.
* tests/scripts/targets/POSIX: sh -x prints differently.
* tests/scripts/variables/SHELL: Ditto.
2023-01-08 10:45:38 -05:00

144 lines
2.9 KiB
Perl

# -*-perl-*-
$description = "Test the behaviour of the .ONESHELL target.";
$details = "";
my $multi_ok = 0;
if ($port_type ne 'W32') {
# Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
# separate arguments.
my $t = `$sh_name -e -c true 2>/dev/null`;
$multi_ok = $? == 0;
}
# Simple
run_make_test(q!
.ONESHELL:
all:
a=$$$$
[ 0"$$a" -eq "$$$$" ] || echo fail
!,
'', 'a=$$
[ 0"$a" -eq "$$" ] || echo fail
');
# Simple but use multi-word SHELLFLAGS
if ($multi_ok) {
run_make_test(q!
.ONESHELL:
.SHELLFLAGS = -e -c
all:
a=$$$$
[ 0"$$a" -eq "$$$$" ] || echo fail
!,
'', 'a=$$
[ 0"$a" -eq "$$" ] || echo fail
');
}
# Again, but this time with inner prefix chars
run_make_test(q!
.ONESHELL:
all:
a=$$$$
@-+ [ 0"$$a" -eq "$$$$" ] || echo fail
!,
'', 'a=$$
[ 0"$a" -eq "$$" ] || echo fail
');
# This time with outer prefix chars
run_make_test(q!
.ONESHELL:
all:
@a=$$$$
[ 0"$$a" -eq "$$$$" ] || echo fail
!,
'', '');
# This time with outer and inner prefix chars
run_make_test(q!
.ONESHELL:
all:
@a=$$$$
-@ +[ 0"$$a" -eq "$$$$" ] || echo fail
!,
'', '');
# Now try using a different interpreter
# This doesn't work on Windows right now
if ($port_type ne 'W32') {
run_make_test(q!
.RECIPEPREFIX = >
.ONESHELL:
SHELL = #PERL#
.SHELLFLAGS = -e
all:
> @$$a=5
> +7;
> @y=qw(a b c);
>print "a = $$a, y = (@y)\n";
!,
'', "a = 12, y = (a b c)\n");
# Simple .SHELLFLAGS, no quotes.
# sv 61805.
run_make_test(q!
.ONESHELL:
SHELL = #PERL#
.SHELLFLAGS = -e
all:; @print "it works\n"
!, '', 'it works');
# Pass a quoted string with spaces to oneshell.
# sv 61805.
run_make_test(q!
.ONESHELL:
SHELL = #PERL#
.SHELLFLAGS = -w -E 'use warnings FATAL => "all";' -E
all:; @print "it works\n"
!, '', 'it works');
# Empty .SHELLFLAGS.
# sv 61805.
run_make_test(q!
.ONESHELL:
SHELL = #PERL#
.SHELLFLAGS =
all:; @print "it works"
!, '', "Can't open perl script \"print \"it works\"\": $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:5: all] Error $ERR_no_such_file_code", 512);
# No .SHELLFLAGS.
# sv 61805.
run_make_test(q!
.ONESHELL:
SHELL = #PERL#
all:; @print "it works"
!, '', "Can't open perl script \"print \"it works\"\": $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:4: all] Error $ERR_no_such_file_code", 512);
# Pass a quoted string with spaces to oneshell.
# sv 61805.
run_make_test(q!
.ONESHELL:
SHELL = #PERL#
.SHELLFLAGS = -w -E 'use warnings FATAL => "all";' -E 'my $$foo = "bar";' -E
all:; @print "it works: $$foo\n"
!, '', 'it works: bar');
}
# This tells the test driver that the perl test script executed properly.
1;
### Local Variables:
### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
### End: