make(1): add tests for variable expansion in .ERROR handling
This commit is contained in:
parent
73287a0b22
commit
95fe5be41c
|
@ -1,15 +1,15 @@
|
|||
: Making success1 out of nothing.
|
||||
: Making fail1 out of nothing.
|
||||
false
|
||||
false 'fail1' '${.TARGET}' '$${.TARGET}'
|
||||
*** Error code 1 (continuing)
|
||||
: Making success2 out of nothing.
|
||||
: Making fail2 out of nothing.
|
||||
false
|
||||
false 'fail2' '${.TARGET}' '$${.TARGET}'
|
||||
*** Error code 1 (continuing)
|
||||
: Making success3 out of nothing.
|
||||
|
||||
Stop.
|
||||
make: stopped in unit-tests
|
||||
target: success3
|
||||
command:
|
||||
.ERROR target: <success3>
|
||||
.ERROR command: <>
|
||||
exit status 1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: compat-error.mk,v 1.1 2020/12/13 17:44:31 rillig Exp $
|
||||
# $NetBSD: compat-error.mk,v 1.2 2020/12/13 19:08:20 rillig Exp $
|
||||
#
|
||||
# Test detailed error handling in compat mode.
|
||||
#
|
||||
|
@ -26,8 +26,8 @@ success1 success2 success3:
|
|||
|
||||
fail1 fail2:
|
||||
: Making ${.TARGET} out of nothing.
|
||||
false
|
||||
false '${.TARGET}' '$${.TARGET}' '$$$${.TARGET}'
|
||||
|
||||
.ERROR:
|
||||
@echo target: ${.ERROR_TARGET}
|
||||
@echo command: ${.ERROR_CMD}
|
||||
@echo ${.TARGET} target: '<'${.ERROR_TARGET:Q}'>'
|
||||
@echo ${.TARGET} command: '<'${.ERROR_CMD:Q}'>'
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
fail
|
||||
echo fail all; false 'all' '${.TARGET}' '$${.TARGET}'
|
||||
fail all
|
||||
*** [all] Error code 1
|
||||
|
||||
make: stopped in unit-tests
|
||||
.ERROR_TARGET='all'
|
||||
.ERROR_CMD='@: command before @echo fail; false @: command after, with variable expressions expanded'
|
||||
.ERROR_CMD='@: before '${.TARGET}' '${.TARGET}' '$${.TARGET}' echo fail ${.TARGET}; false '${.TARGET}' '${.TARGET}' '$${.TARGET}' @: after '${.TARGET}' '${.TARGET}' '$${.TARGET}''
|
||||
exit status 1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: varname-make_print_var_on_error-jobs.mk,v 1.1 2020/10/23 06:18:23 rillig Exp $
|
||||
# $NetBSD: varname-make_print_var_on_error-jobs.mk,v 1.2 2020/12/13 19:08:20 rillig Exp $
|
||||
#
|
||||
# Tests for the special MAKE_PRINT_VAR_ON_ERROR variable, which prints the
|
||||
# values of selected variables on error.
|
||||
|
@ -9,6 +9,13 @@
|
|||
# The commands in .ERROR_CMD are space-separated. Since each command usually
|
||||
# contains spaces as well, this value is only intended as a first hint to what
|
||||
# happened. For more details, use the debug options -de, -dj, -dl, -dn, -dx.
|
||||
#
|
||||
# See also:
|
||||
# compat-error.mk
|
||||
|
||||
# XXX: As of 2020-12-13, PrintOnError calls Var_Subst with VAR_GLOBAL, which
|
||||
# does not expand the node-local variables like .TARGET. This results in the
|
||||
# double '${.TARGET}' in the output.
|
||||
|
||||
# As of 2020-10-23, .ERROR_CMD only works in parallel mode.
|
||||
.MAKEFLAGS: -j1
|
||||
|
@ -16,6 +23,6 @@
|
|||
MAKE_PRINT_VAR_ON_ERROR= .ERROR_TARGET .ERROR_CMD
|
||||
|
||||
all:
|
||||
@: command before
|
||||
@echo fail; false
|
||||
@: command after${:U, with variable expressions expanded}
|
||||
@: before '${.TARGET}' '$${.TARGET}' '$$$${.TARGET}'
|
||||
echo fail ${.TARGET}; false '${.TARGET}' '$${.TARGET}' '$$$${.TARGET}'
|
||||
@: after '${.TARGET}' '$${.TARGET}' '$$$${.TARGET}'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
fail
|
||||
echo fail all; false 'all' '${.TARGET}' '$${.TARGET}'
|
||||
fail all
|
||||
*** Error code 1 (continuing)
|
||||
|
||||
Stop.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: varname-make_print_var_on_error.mk,v 1.4 2020/10/23 06:18:23 rillig Exp $
|
||||
# $NetBSD: varname-make_print_var_on_error.mk,v 1.5 2020/12/13 19:08:20 rillig Exp $
|
||||
#
|
||||
# Tests for the special MAKE_PRINT_VAR_ON_ERROR variable, which prints the
|
||||
# values of selected variables on error.
|
||||
|
@ -7,10 +7,17 @@
|
|||
# since at the point where it is filled in PrintOnError, the first command in
|
||||
# gn->commands has been set to NULL already. This leaves .ERROR_CMD an empty
|
||||
# list.
|
||||
#
|
||||
# See also:
|
||||
# compat-error.mk
|
||||
|
||||
# XXX: As of 2020-12-13, PrintOnError calls Var_Subst with VAR_GLOBAL, which
|
||||
# does not expand the node-local variables like .TARGET. This results in the
|
||||
# double '${.TARGET}' in the output.
|
||||
|
||||
MAKE_PRINT_VAR_ON_ERROR= .ERROR_TARGET .ERROR_CMD
|
||||
|
||||
all:
|
||||
@: command before
|
||||
@echo fail; false
|
||||
@: command after
|
||||
@: before '${.TARGET}' '$${.TARGET}' '$$$${.TARGET}'
|
||||
echo fail ${.TARGET}; false '${.TARGET}' '$${.TARGET}' '$$$${.TARGET}'
|
||||
@: after '${.TARGET}' '$${.TARGET}' '$$$${.TARGET}'
|
||||
|
|
Loading…
Reference in New Issue