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 more tests for edge cas...



details:   https://anonhg.NetBSD.org/src/rev/e3888603aefa
branches:  trunk
changeset: 950216:e3888603aefa
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jan 21 13:32:17 2021 +0000

description:
make(1): add more tests for edge cases in conditionals

diffstat:

 usr.bin/make/unit-tests/cond-token-plain.exp |  13 +++++++++-
 usr.bin/make/unit-tests/cond-token-plain.mk  |  36 +++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 2 deletions(-)

diffs (70 lines):

diff -r 47f0d8bd63bb -r e3888603aefa usr.bin/make/unit-tests/cond-token-plain.exp
--- a/usr.bin/make/unit-tests/cond-token-plain.exp      Thu Jan 21 13:31:38 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-token-plain.exp      Thu Jan 21 13:32:17 2021 +0000
@@ -38,4 +38,15 @@
 make: "cond-token-plain.mk" line 130: Numbers can be composed from literals and variable expressions.
 CondParser_Eval: 0${:Ux01}
 make: "cond-token-plain.mk" line 134: Numbers can be composed from literals and variable expressions.
-exit status 0
+CondParser_Eval: "" ==
+make: "cond-token-plain.mk" line 140: warning: Missing right-hand-side of operator
+make: "cond-token-plain.mk" line 140: Malformed conditional ("" ==)
+CondParser_Eval: == ""
+make: "cond-token-plain.mk" line 148: Malformed conditional (== "")
+CondParser_Eval: \\
+make: "cond-token-plain.mk" line 163: The variable '\\' is not defined.
+CondParser_Eval: \\
+make: "cond-token-plain.mk" line 168: Now the variable '\\' is defined.
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r 47f0d8bd63bb -r e3888603aefa usr.bin/make/unit-tests/cond-token-plain.mk
--- a/usr.bin/make/unit-tests/cond-token-plain.mk       Thu Jan 21 13:31:38 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-token-plain.mk       Thu Jan 21 13:32:17 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-plain.mk,v 1.7 2021/01/21 00:38:28 rillig Exp $
+# $NetBSD: cond-token-plain.mk,v 1.8 2021/01/21 13:32:17 rillig Exp $
 #
 # Tests for plain tokens (that is, string literals without quotes)
 # in .if conditions.
@@ -136,6 +136,40 @@
 .  error
 .endif
 
+# If the right-hand side is missing, it's a parse error.
+.if "" ==
+.  error
+.else
+.  error
+.endif
+
+# If the left-hand side is missing, it's a parse error as well, but without
+# a specific error message.
+.if == ""
+.  error
+.else
+.  error
+.endif
+
+# The '\\' is not a line continuation.  Neither is it an unquoted string
+# literal.  Instead, it is parsed as a function argument (ParseFuncArg),
+# and in that context, the backslash is just an ordinary character. The
+# function argument thus stays '\\' (2 backslashes).  This string is passed
+# to FuncDefined, and since there is no variable named '\\', the condition
+# evaluates to false.
+.if \\
+.  error
+.else
+.  info The variable '\\' is not defined.
+.endif
+
+${:U\\\\}=     backslash
+.if \\
+.  info Now the variable '\\' is defined.
+.else
+.  error
+.endif
+
 # See cond-token-string.mk for similar tests where the condition is enclosed
 # in "quotes".
 



Home | Main Index | Thread Index | Old Index