Module Name:    src
Committed By:   rillig
Date:           Sun Dec 13 19:08:20 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: compat-error.exp compat-error.mk
            varname-make_print_var_on_error-jobs.exp
            varname-make_print_var_on_error-jobs.mk
            varname-make_print_var_on_error.exp
            varname-make_print_var_on_error.mk

Log Message:
make(1): add tests for variable expansion in .ERROR handling


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/compat-error.exp \
    src/usr.bin/make/unit-tests/compat-error.mk \
    src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp \
    src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk
cvs rdiff -u -r1.2 -r1.3 \
    src/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp
cvs rdiff -u -r1.4 -r1.5 \
    src/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/compat-error.exp
diff -u src/usr.bin/make/unit-tests/compat-error.exp:1.1 src/usr.bin/make/unit-tests/compat-error.exp:1.2
--- src/usr.bin/make/unit-tests/compat-error.exp:1.1	Sun Dec 13 17:44:31 2020
+++ src/usr.bin/make/unit-tests/compat-error.exp	Sun Dec 13 19:08:20 2020
@@ -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
Index: src/usr.bin/make/unit-tests/compat-error.mk
diff -u src/usr.bin/make/unit-tests/compat-error.mk:1.1 src/usr.bin/make/unit-tests/compat-error.mk:1.2
--- src/usr.bin/make/unit-tests/compat-error.mk:1.1	Sun Dec 13 17:44:31 2020
+++ src/usr.bin/make/unit-tests/compat-error.mk	Sun Dec 13 19:08:20 2020
@@ -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}'>'
Index: src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp
diff -u src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp:1.1 src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp:1.2
--- src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp:1.1	Fri Oct 23 06:18:23 2020
+++ src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp	Sun Dec 13 19:08:20 2020
@@ -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
Index: src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk
diff -u src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk:1.1 src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk:1.2
--- src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk:1.1	Fri Oct 23 06:18:23 2020
+++ src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk	Sun Dec 13 19:08:20 2020
@@ -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}'

Index: src/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp
diff -u src/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp:1.2 src/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp:1.3
--- src/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp:1.2	Fri Oct 23 05:44:02 2020
+++ src/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp	Sun Dec 13 19:08:20 2020
@@ -1,4 +1,5 @@
-fail
+echo fail all; false 'all' '${.TARGET}' '$${.TARGET}'
+fail all
 *** Error code 1 (continuing)
 
 Stop.

Index: src/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk
diff -u src/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk:1.4 src/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk:1.5
--- src/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk:1.4	Fri Oct 23 06:18:23 2020
+++ src/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk	Sun Dec 13 19:08:20 2020
@@ -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}'

Reply via email to