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 tests/make: demonstrate recursive va...
details: https://anonhg.NetBSD.org/src/rev/071653d40af3
branches: trunk
changeset: 359877:071653d40af3
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jan 29 10:09:37 2022 +0000
description:
tests/make: demonstrate recursive variable in target
diffstat:
usr.bin/make/unit-tests/var-recursive.exp | 4 ++++
usr.bin/make/unit-tests/var-recursive.mk | 16 ++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diffs (46 lines):
diff -r 6f816710a11a -r 071653d40af3 usr.bin/make/unit-tests/var-recursive.exp
--- a/usr.bin/make/unit-tests/var-recursive.exp Sat Jan 29 09:38:26 2022 +0000
+++ b/usr.bin/make/unit-tests/var-recursive.exp Sat Jan 29 10:09:37 2022 +0000
@@ -12,4 +12,8 @@
in var-recursive.mk:43
make: stopped in unit-tests
+: OK
+Variable VAR is recursive.
+
+make: stopped in unit-tests
exit status 0
diff -r 6f816710a11a -r 071653d40af3 usr.bin/make/unit-tests/var-recursive.mk
--- a/usr.bin/make/unit-tests/var-recursive.mk Sat Jan 29 09:38:26 2022 +0000
+++ b/usr.bin/make/unit-tests/var-recursive.mk Sat Jan 29 10:09:37 2022 +0000
@@ -1,9 +1,9 @@
-# $NetBSD: var-recursive.mk,v 1.2 2020/10/31 13:45:00 rillig Exp $
+# $NetBSD: var-recursive.mk,v 1.3 2022/01/29 10:09:37 rillig Exp $
#
# Tests for variable expressions that refer to themselves and thus
# cannot be evaluated.
-TESTS= direct indirect conditional short
+TESTS= direct indirect conditional short target
# Since make exits immediately when it detects a recursive expression,
# the actual tests are run in sub-makes.
@@ -42,6 +42,18 @@
V= $V
. info $V
+.elif ${TEST} == target
+
+# If a recursive variable is accessed in a command of a target, the makefiles
+# are not parsed anymore, so there is no location information from the
+# .includes and .for directives. TODO: In such a case, use the target
+# definition to provide at least a hint to the location.
+VAR= ${VAR}
+target:
+ : OK
+ : ${VAR}
+ : OK
+
.else
. error Unknown test "${TEST}"
.endif
Home |
Main Index |
Thread Index |
Old Index