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 test for variable expre...
details: https://anonhg.NetBSD.org/src/rev/b510bb22a158
branches: trunk
changeset: 1013059:b510bb22a158
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Aug 20 19:43:42 2020 +0000
description:
make(1): add test for variable expressions in conditions
diffstat:
usr.bin/make/unit-tests/cond-token-var.exp | 8 ++++++-
usr.bin/make/unit-tests/cond-token-var.mk | 34 ++++++++++++++++++++++++++---
2 files changed, 37 insertions(+), 5 deletions(-)
diffs (54 lines):
diff -r 9da3f8a50059 -r b510bb22a158 usr.bin/make/unit-tests/cond-token-var.exp
--- a/usr.bin/make/unit-tests/cond-token-var.exp Thu Aug 20 18:47:57 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-token-var.exp Thu Aug 20 19:43:42 2020 +0000
@@ -1,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
diff -r 9da3f8a50059 -r b510bb22a158 usr.bin/make/unit-tests/cond-token-var.mk
--- a/usr.bin/make/unit-tests/cond-token-var.mk Thu Aug 20 18:47:57 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-token-var.mk Thu Aug 20 19:43:42 2020 +0000
@@ -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
+
+# 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
-all:
- @:;
+# 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
Home |
Main Index |
Thread Index |
Old Index