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 unquoted strin...



details:   https://anonhg.NetBSD.org/src/rev/1a02bb968b9b
branches:  trunk
changeset: 937887:1a02bb968b9b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 28 14:07:51 2020 +0000

description:
make(1): add test for unquoted string literals

diffstat:

 usr.bin/make/unit-tests/cond-op.exp |   6 +++++-
 usr.bin/make/unit-tests/cond-op.mk  |  20 +++++++++++++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diffs (43 lines):

diff -r 6c39d6256e73 -r 1a02bb968b9b usr.bin/make/unit-tests/cond-op.exp
--- a/usr.bin/make/unit-tests/cond-op.exp       Fri Aug 28 13:56:29 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-op.exp       Fri Aug 28 14:07:51 2020 +0000
@@ -1,1 +1,5 @@
-exit status 0
+make: "cond-op.mk" line 45: Malformed conditional ("!word" == !word)
+make: "cond-op.mk" line 57: Parsing continues until here.
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r 6c39d6256e73 -r 1a02bb968b9b usr.bin/make/unit-tests/cond-op.mk
--- a/usr.bin/make/unit-tests/cond-op.mk        Fri Aug 28 13:56:29 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-op.mk        Fri Aug 28 14:07:51 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op.mk,v 1.3 2020/08/28 13:50:48 rillig Exp $
+# $NetBSD: cond-op.mk,v 1.4 2020/08/28 14:07:51 rillig Exp $
 #
 # Tests for operators like &&, ||, ! in .if conditions.
 #
@@ -38,5 +38,23 @@
 # makes a difference.  There is a simple example for sure, I just cannot
 # wrap my head around it.
 
+# This condition is malformed because the '!' on the right-hand side must not
+# appear unquoted.  If any, it must be enclosed in quotes.
+# In any case, it is not interpreted as a negation of an unquoted string.
+# See CondGetString.
+.if "!word" == !word
+.error
+.endif
+
+# Surprisingly, the ampersand and pipe are allowed in bare strings.
+# That's another opportunity for writing confusing code.
+# See CondGetString, which only has '!' in the list of stop characters.
+.if "a&&b||c" != a&&b||c
+.error
+.endif
+
+# Just in case that parsing should ever stop on the first error.
+.info Parsing continues until here.
+
 all:
        @:;



Home | Main Index | Thread Index | Old Index