Module Name: src
Committed By: rillig
Date: Sun Mar 14 19:16:41 UTC 2021
Modified Files:
src/usr.bin/make/unit-tests: var-eval-short.exp var-eval-short.mk
Log Message:
tests/make: add test for the ':?' modifier in parse-only mode
The debug output for this scenario will change a bit in an upcoming
commit, but that will not affect anything outside the debug log.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-eval-short.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/var-eval-short.exp
diff -u src/usr.bin/make/unit-tests/var-eval-short.exp:1.3 src/usr.bin/make/unit-tests/var-eval-short.exp:1.4
--- src/usr.bin/make/unit-tests/var-eval-short.exp:1.3 Sun Mar 14 18:02:44 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.exp Sun Mar 14 19:16:41 2021
@@ -4,6 +4,26 @@ make: "var-eval-short.mk" line 63: Inval
make: "var-eval-short.mk" line 63: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
make: "var-eval-short.mk" line 77: Invalid time value: ${FAIL}}
make: "var-eval-short.mk" line 77: Malformed conditional (0 && ${:Uword:localtime=${FAIL}})
+CondParser_Eval: 0 && ${0:?${FAIL}then:${FAIL}else}
+Var_Parse: ${0:?${FAIL}then:${FAIL}else} with none
+Applying ${0:?...} to "" (none, none, undefined)
+Modifier part: "${FAIL}then"
+Modifier part: "${FAIL}else"
+Result of ${0:?${FAIL}then:${FAIL}else} is "${FAIL}else" (none, none, defined)
+ParseReadLine (141): 'DEFINED= defined'
+Global:DEFINED = defined
+CondParser_Eval: 0 && ${DEFINED:L:?${FAIL}then:${FAIL}else}
+Var_Parse: ${DEFINED:L:?${FAIL}then:${FAIL}else} with none
+Applying ${DEFINED:L} to "defined" (none, none, regular)
+Result of ${DEFINED:L} is "defined" (none, none, regular)
+Applying ${DEFINED:?...} to "defined" (none, none, regular)
+Modifier part: "${FAIL}then"
+Modifier part: "${FAIL}else"
+Result of ${DEFINED:?${FAIL}then:${FAIL}else} is "${FAIL}else" (none, none, regular)
+ParseReadLine (144): '.MAKEFLAGS: -d0'
+ParseDoDependency(.MAKEFLAGS: -d0)
+Global:.MAKEFLAGS = -r -k -d cpv -d
+Global:.MAKEFLAGS = -r -k -d cpv -d 0
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/var-eval-short.mk
diff -u src/usr.bin/make/unit-tests/var-eval-short.mk:1.1 src/usr.bin/make/unit-tests/var-eval-short.mk:1.2
--- src/usr.bin/make/unit-tests/var-eval-short.mk:1.1 Sun Mar 14 11:49:37 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.mk Sun Mar 14 19:16:41 2021
@@ -1,4 +1,4 @@
-# $NetBSD: var-eval-short.mk,v 1.1 2021/03/14 11:49:37 rillig Exp $
+# $NetBSD: var-eval-short.mk,v 1.2 2021/03/14 19:16:41 rillig Exp $
#
# Tests for each variable modifier to ensure that they only do the minimum
# necessary computations. If the result of the expression is not needed, they
@@ -125,4 +125,22 @@ DEFINED= # defined
.if 0 && ${:Uword:word=replacement}
.endif
+# Before var.c 1.XXX from 2021-03-14, Var_Parse returned "${FAIL}else" for the
+# irrelevant right-hand side of the condition, even though this was not
+# necessary. Since the return value from Var_Parse is supposed to be ignored
+# anyway, and since it is actually ignored in an overly complicated way,
+# an empty string suffices.
+.MAKEFLAGS: -dcpv
+.if 0 && ${0:?${FAIL}then:${FAIL}else}
+.endif
+
+# The ':L' is applied before the ':?' modifier, giving the expression a name
+# and a value, just to see whether this value gets passed through or whether
+# the parse-only mode results in an empty string (only visible in the debug
+# log).
+DEFINED= defined
+.if 0 && ${DEFINED:L:?${FAIL}then:${FAIL}else}
+.endif
+.MAKEFLAGS: -d0
+
all: