Module Name: src
Committed By: rillig
Date: Thu Aug 20 19:43:42 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: cond-token-var.exp cond-token-var.mk
Log Message:
make(1): add test for variable expressions in conditions
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-token-var.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-token-var.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/cond-token-var.exp
diff -u src/usr.bin/make/unit-tests/cond-token-var.exp:1.1 src/usr.bin/make/unit-tests/cond-token-var.exp:1.2
--- src/usr.bin/make/unit-tests/cond-token-var.exp:1.1 Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/cond-token-var.exp Thu Aug 20 19:43:42 2020
@@ -1 +1,7 @@
-exit status 0
+make: "cond-token-var.mk" line 9: ok
+make: "cond-token-var.mk" line 15: Malformed conditional (${UNDEF} == ${DEF})
+make: "cond-token-var.mk" line 20: Malformed conditional (${DEF} == ${UNDEF})
+make: "cond-token-var.mk" line 29: Malformed conditional (${UNDEF})
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/cond-token-var.mk
diff -u src/usr.bin/make/unit-tests/cond-token-var.mk:1.2 src/usr.bin/make/unit-tests/cond-token-var.mk:1.3
--- src/usr.bin/make/unit-tests/cond-token-var.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/cond-token-var.mk Thu Aug 20 19:43:42 2020
@@ -1,8 +1,34 @@
-# $NetBSD: cond-token-var.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: cond-token-var.mk,v 1.3 2020/08/20 19:43:42 rillig Exp $
#
# Tests for variables in .if conditions.
-# TODO: Implementation
+DEF= defined
-all:
- @:;
+# A defined variable may appear on either side of the comparison.
+.if ${DEF} == ${DEF}
+.info ok
+.else
+.error
+.endif
+
+# A variable that appears on the left-hand side must be defined.
+.if ${UNDEF} == ${DEF}
+.error
+.endif
+
+# A variable that appears on the right-hand side must be defined.
+.if ${DEF} == ${UNDEF}
+.error
+.endif
+
+# A defined variable may appear as an expression of its own.
+.if ${DEF}
+.endif
+
+# An undefined variable generates a warning.
+.if ${UNDEF}
+.endif
+
+# The :U modifier turns an undefined variable into an ordinary expression.
+.if ${UNDEF:U}
+.endif