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 variable name ...



details:   https://anonhg.NetBSD.org/src/rev/e48f4e0c34a1
branches:  trunk
changeset: 945186:e48f4e0c34a1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 23 17:21:22 2020 +0000

description:
make(1): add test for variable name aliasing

diffstat:

 usr.bin/make/unit-tests/var-class-local.mk |  22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diffs (33 lines):

diff -r 672c8e723d8b -r e48f4e0c34a1 usr.bin/make/unit-tests/var-class-local.mk
--- a/usr.bin/make/unit-tests/var-class-local.mk        Fri Oct 23 17:05:40 2020 +0000
+++ b/usr.bin/make/unit-tests/var-class-local.mk        Fri Oct 23 17:21:22 2020 +0000
@@ -1,8 +1,28 @@
-# $NetBSD: var-class-local.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: var-class-local.mk,v 1.3 2020/10/23 17:21:22 rillig Exp $
 #
 # Tests for target-local variables, such as ${.TARGET} or $@.
 
 # TODO: Implementation
 
+# Ensure that the name of the variable is exactly the given one.
+# The variable "@" is an alias for ".TARGET", so the implementation might
+# canonicalize these aliases at some point, and that might be surprising.
+# This aliasing happens for single-character variable names like $@ or $<
+# (see VarFind, CanonicalVarname), but not for braced or parenthesized
+# expressions like ${@}, ${.TARGET} ${VAR:Mpattern} (see Var_Parse,
+# ParseVarname).
+.if ${@:L} != "@"
+.  error
+.endif
+.if ${.TARGET:L} != ".TARGET"
+.  error
+.endif
+.if ${@F:L} != "@F"
+.  error
+.endif
+.if ${@D:L} != "@D"
+.  error
+.endif
+
 all:
        @:;



Home | Main Index | Thread Index | Old Index