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 tests for edge cases in...
details: https://anonhg.NetBSD.org/src/rev/c0ae0da87c98
branches: trunk
changeset: 945940:c0ae0da87c98
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Nov 10 19:36:50 2020 +0000
description:
make(1): add tests for edge cases in parsing conditionals
diffstat:
usr.bin/make/unit-tests/cond-func.exp | 5 ++++
usr.bin/make/unit-tests/cond-func.mk | 40 ++++++++++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 1 deletions(-)
diffs (68 lines):
diff -r e192a173762a -r c0ae0da87c98 usr.bin/make/unit-tests/cond-func.exp
--- a/usr.bin/make/unit-tests/cond-func.exp Tue Nov 10 19:14:11 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-func.exp Tue Nov 10 19:36:50 2020 +0000
@@ -4,6 +4,11 @@
make: "cond-func.mk" line 49: Malformed conditional (!defined(A&B))
make: "cond-func.mk" line 52: warning: Missing closing parenthesis for defined()
make: "cond-func.mk" line 52: Malformed conditional (!defined(A|B))
+make: "cond-func.mk" line 92: The empty variable is never defined.
+make: "cond-func.mk" line 100: A plain function name is parsed as !empty(...).
+make: "cond-func.mk" line 107: A plain function name is parsed as !empty(...).
+make: "cond-func.mk" line 117: Symbols may start with a function name.
+make: "cond-func.mk" line 122: Symbols may start with a function name.
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
diff -r e192a173762a -r c0ae0da87c98 usr.bin/make/unit-tests/cond-func.mk
--- a/usr.bin/make/unit-tests/cond-func.mk Tue Nov 10 19:14:11 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-func.mk Tue Nov 10 19:36:50 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func.mk,v 1.6 2020/11/08 21:40:13 rillig Exp $
+# $NetBSD: cond-func.mk,v 1.7 2020/11/10 19:36:50 rillig Exp $
#
# Tests for those parts of the functions in .if conditions that are common
# among several functions.
@@ -86,5 +86,43 @@
. error
.endif
+.if defined()
+. error
+.else
+. info The empty variable is never defined.
+.endif
+
+# The plain word 'defined' is interpreted as '!empty(defined)'.
+# That variable is not defined (yet).
+.if defined
+. error
+.else
+. info A plain function name is parsed as !empty(...).
+.endif
+
+# If a variable named 'defined' is actually defined and not empty, the plain
+# symbol 'defined' evaluates to true.
+defined= non-empty
+.if defined
+. info A plain function name is parsed as !empty(...).
+.else
+. error
+.endif
+
+# A plain symbol name may start with one of the function names, in this case
+# 'defined'.
+.if defined-var
+. error
+.else
+. info Symbols may start with a function name.
+.endif
+
+defined-var= non-empty
+.if defined-var
+. info Symbols may start with a function name.
+.else
+. error
+.endif
+
all:
@:;
Home |
Main Index |
Thread Index |
Old Index