mirror of
https://git.savannah.gnu.org/git/make.git
synced 2025-02-05 14:07:46 +00:00
047bd5a16f
While displaying line numbers, show the relevant line number inside the recipe not just the first line of the entire recipe. Sample changes suggested by Brian Vandenberg <phantall@gmail.com> * gnumake.h (gmk_floc): Add an 'offset' to track the recipe offset. * read.c (eval, eval_makefile, eval_buffer): Initialize 'offset'. (record_files, install_pattern_rule): Ditto. * job.c (new_job, job_next_command): Update 'offset' based on the line of the recipe we're expanding or invoking. (child_error): Add 'offset' when showing the line number. * function.c (func_shell_base): Ditto. * output.c (error, fatal): Ditto. * NEWS: Mention the new ability. * tests/scripts/features/errors: Check the line number on errors. * tests/scripts/functions/warning: Check the line number on warnings. * tests/scripts/features/output-sync, tests/scripts/features/parallelism, tests/scripts/functions/shell, tests/scripts/functions/error: Update line numbers.
60 lines
1.3 KiB
Perl
60 lines
1.3 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
|
|
if ($all_tests) {
|
|
run_make_test(q!
|
|
FOO := $(shell echo '#')
|
|
foo: ; echo '$(FOO)'
|
|
!,
|
|
'', "#\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');
|
|
|
|
# Test shell errors in recipes including offset
|
|
run_make_test('
|
|
all:
|
|
@echo hi
|
|
$(shell ./basdfdfsed there)
|
|
@echo there
|
|
',
|
|
'', "#MAKE#: ./basdfdfsed: Command not found\nhi\nthere\n");
|
|
|
|
1;
|
|
|
|
### Local Variables:
|
|
### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
|
|
### End:
|