Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add tests for variable expa...



details:   https://anonhg.NetBSD.org/src/rev/c596ddf21ed1
branches:  trunk
changeset: 1017136:c596ddf21ed1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 13 19:08:20 2020 +0000

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

diffstat:

 usr.bin/make/unit-tests/compat-error.exp                         |   8 ++--
 usr.bin/make/unit-tests/compat-error.mk                          |   8 ++--
 usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp |   5 ++-
 usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk  |  15 +++++++--
 usr.bin/make/unit-tests/varname-make_print_var_on_error.exp      |   3 +-
 usr.bin/make/unit-tests/varname-make_print_var_on_error.mk       |  15 +++++++--
 6 files changed, 35 insertions(+), 19 deletions(-)

diffs (131 lines):

diff -r 49281d1ae690 -r c596ddf21ed1 usr.bin/make/unit-tests/compat-error.exp
--- a/usr.bin/make/unit-tests/compat-error.exp  Sun Dec 13 18:57:44 2020 +0000
+++ b/usr.bin/make/unit-tests/compat-error.exp  Sun Dec 13 19:08:20 2020 +0000
@@ -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
diff -r 49281d1ae690 -r c596ddf21ed1 usr.bin/make/unit-tests/compat-error.mk
--- a/usr.bin/make/unit-tests/compat-error.mk   Sun Dec 13 18:57:44 2020 +0000
+++ b/usr.bin/make/unit-tests/compat-error.mk   Sun Dec 13 19:08:20 2020 +0000
@@ -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 @@
 
 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}'>'
diff -r 49281d1ae690 -r c596ddf21ed1 usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp
--- a/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp  Sun Dec 13 18:57:44 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp  Sun Dec 13 19:08:20 2020 +0000
@@ -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
diff -r 49281d1ae690 -r c596ddf21ed1 usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk
--- a/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk   Sun Dec 13 18:57:44 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk   Sun Dec 13 19:08:20 2020 +0000
@@ -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}'
diff -r 49281d1ae690 -r c596ddf21ed1 usr.bin/make/unit-tests/varname-make_print_var_on_error.exp
--- a/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp       Sun Dec 13 18:57:44 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp       Sun Dec 13 19:08:20 2020 +0000
@@ -1,4 +1,5 @@
-fail
+echo fail all; false 'all' '${.TARGET}' '$${.TARGET}'
+fail all
 *** Error code 1 (continuing)
 
 Stop.
diff -r 49281d1ae690 -r c596ddf21ed1 usr.bin/make/unit-tests/varname-make_print_var_on_error.mk
--- a/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk        Sun Dec 13 18:57:44 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk        Sun Dec 13 19:08:20 2020 +0000
@@ -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}'



Home | Main Index | Thread Index | Old Index