make/tests/scripts/functions/shell
Paul Smith fa937343f5 Clean up errors for invalid commands and add regression tests.
* src/function.c (func_shell_base): Use error() instead of recreating
the error output.
* src/job.c (exec_command): Show more standard error messages.
* src/load.c (unload_file): Fix whitespace in the error message.
* tests/scripts/features/errors: Add tests for starting non-
existent commands and new error message formats.
* tests/scripts/features/output-sync: New error message formats.
* tests/scripts/functions/shell: Ditto.
2018-08-04 12:37:19 -04:00

76 lines
1.9 KiB
Perl

# -*-perl-*-
$description = 'Test the $(shell ...) function.';
$details = '';
# Test standard shell
run_make_test('.PHONY: all
OUT := $(shell echo hi)
all: ; @echo $(OUT)
','','hi');
# Test shells inside rules.
run_make_test('.PHONY: all
all: ; @echo $(shell echo hi)
','','hi');
# Verify .SHELLSTATUS
run_make_test('.PHONY: all
PRE := $(.SHELLSTATUS)
$(shell exit 0)
OK := $(.SHELLSTATUS)
$(shell exit 1)
BAD := $(.SHELLSTATUS)
all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD)
','','PRE= OK=0 BAD=1');
# Test unescaped comment characters in shells. Savannah bug #20513
run_make_test(q!
FOO := $(shell echo '#')
foo: ; echo '$(FOO)'
!,
'', "echo '#'\n#\n");
# Test shells inside exported environment variables.
# This is the test that fails if we try to put make exported variables into
# the environment for a $(shell ...) call.
run_make_test('
export HI = $(shell echo hi)
.PHONY: all
all: ; @echo $$HI
','','hi');
if ($port_type ne 'W32') {
# Test shell errors in recipes including offset
# This needs to be ported to Windows, or else Windows error messages
# need to converted to look like more normal make errors.
run_make_test('
all:
@echo hi
$(shell ./basdfdfsed there)
@echo $(.SHELLSTATUS)
',
'', "#MAKE#: ./basdfdfsed: $ERR_no_such_file\nhi\n127\n");
run_make_test('
$(shell ./basdfdfsed where)
all: ; @echo $(.SHELLSTATUS)
',
'', "#MAKE#: ./basdfdfsed: $ERR_no_such_file\n127\n");
# Test SHELLSTATUS for kill.
# This test could be ported to Windows, using taskkill ... ?
run_make_test('.PHONY: all
$(shell kill -2 $$$$)
SIG := $(.SHELLSTATUS)
all: ; @echo SIG=$(SIG)
','','SIG=130');
}
1;
### Local Variables:
### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
### End: