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 parsing ob ob...



details:   https://anonhg.NetBSD.org/src/rev/55de389f7b92
branches:  trunk
changeset: 945644:55de389f7b92
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Nov 02 22:16:24 2020 +0000

description:
make(1): add tests for parsing ob obscure variable names

diffstat:

 usr.bin/make/unit-tests/varname.exp |  22 +++++++++++++++++++++-
 usr.bin/make/unit-tests/varname.mk  |  31 ++++++++++++++++++++++++++++---
 2 files changed, 49 insertions(+), 4 deletions(-)

diffs (66 lines):

diff -r b9731c4458a0 -r 55de389f7b92 usr.bin/make/unit-tests/varname.exp
--- a/usr.bin/make/unit-tests/varname.exp       Mon Nov 02 21:53:28 2020 +0000
+++ b/usr.bin/make/unit-tests/varname.exp       Mon Nov 02 22:16:24 2020 +0000
@@ -1,1 +1,21 @@
-exit status 0
+Global:VAR{{{}}} = 3 braces
+Var_Parse: ${VAR{{{}}}}" != "3 braces" with VARE_WANTRES
+Global:VARNAME = VAR(((
+Var_Parse: ${VARNAME} with VARE_WANTRES
+Global:VAR((( = 3 open parentheses
+Var_Parse: ${VAR(((}}}}" != "3 open parentheses}}}" with VARE_WANTRES
+Var_Parse: ${VAR(((}=  try1 with VARE_UNDEFERR|VARE_WANTRES
+Global:.ALLTARGETS =  3
+Global:.ALLTARGETS =  3 open
+Global:.ALLTARGETS =  3 open parentheses=
+make: "varname.mk" line 27: Need an operator
+Var_Parse: ${VAR\(\(\(}=       try2 with VARE_UNDEFERR|VARE_WANTRES
+Global:.ALLTARGETS =  3 open parentheses= =
+make: "varname.mk" line 28: Need an operator
+Var_Parse: ${VAR\(\(\(}=       try3 with VARE_UNDEFERR|VARE_WANTRES
+make: "varname.mk" line 29: Need an operator
+Global:.MAKEFLAGS =  -r -k -d v -d
+Global:.MAKEFLAGS =  -r -k -d v -d 0
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r b9731c4458a0 -r 55de389f7b92 usr.bin/make/unit-tests/varname.mk
--- a/usr.bin/make/unit-tests/varname.mk        Mon Nov 02 21:53:28 2020 +0000
+++ b/usr.bin/make/unit-tests/varname.mk        Mon Nov 02 22:16:24 2020 +0000
@@ -1,8 +1,33 @@
-# $NetBSD: varname.mk,v 1.4 2020/10/18 08:47:54 rillig Exp $
+# $NetBSD: varname.mk,v 1.5 2020/11/02 22:16:24 rillig Exp $
 #
 # Tests for special variables, such as .MAKE or .PARSEDIR.
+# And for variable names in general.
 
-# TODO: Implementation
+.MAKEFLAGS: -dv
+
+# In variable names, braces are allowed, but they must be balanced.
+# Parentheses and braces may be mixed.
+VAR{{{}}}=     3 braces
+.if "${VAR{{{}}}}" != "3 braces"
+.  error
+.endif
+
+# In variable expressions, the parser works differently.  It doesn't treat
+# braces and parentheses equally, therefore the first closing brace already
+# marks the end of the variable name.
+VARNAME=       VAR(((
+${VARNAME}=    3 open parentheses
+.if "${VAR(((}}}}" != "3 open parentheses}}}"
+.  error
+.endif
+
+# In the above test, the variable name is constructed indirectly.  Neither
+# of the following expressions produces the intended effect.
+# TODO: explain what happens in the parser here.
+${VAR(((}=     try1
+${VAR\(\(\(}=  try2
+${VAR\(\(\(}=  try3
+
+.MAKEFLAGS: -d0
 
 all:
-       @:;



Home | Main Index | Thread Index | Old Index