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 the :D modifier
details: https://anonhg.NetBSD.org/src/rev/30635da5ec5e
branches: trunk
changeset: 943080:30635da5ec5e
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Aug 25 21:58:08 2020 +0000
description:
make(1): add test for the :D modifier
diffstat:
usr.bin/make/unit-tests/varmod-defined.mk | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diffs (34 lines):
diff -r 975dd788ee5f -r 30635da5ec5e usr.bin/make/unit-tests/varmod-defined.mk
--- a/usr.bin/make/unit-tests/varmod-defined.mk Tue Aug 25 21:16:53 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-defined.mk Tue Aug 25 21:58:08 2020 +0000
@@ -1,9 +1,28 @@
-# $NetBSD: varmod-defined.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varmod-defined.mk,v 1.3 2020/08/25 21:58:08 rillig Exp $
#
# Tests for the :D variable modifier, which returns the given string
# if the variable is defined. It is closely related to the :U modifier.
-# TODO: Implementation
+DEF= defined
+.undef UNDEF
+
+# Since DEF is defined, the value of the expression is "value", not
+# "defined".
+#
+.if ${DEF:Dvalue} != "value"
+.error
+.endif
+
+# Since UNDEF is not defined, the "value" is ignored. Instead of leaving the
+# expression undefined, it is set to "", exactly to allow the expression to
+# be used in .if conditions. In this place, other undefined expressions
+# would generate an error message.
+# XXX: Ideally the error message would be "undefined variable", but as of
+# 2020-08-25 it is "Malformed conditional".
+#
+.if ${UNDEF:Dvalue} != ""
+.error
+.endif
all:
@:;
Home |
Main Index |
Thread Index |
Old Index