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): move test for the ::= modif...
details: https://anonhg.NetBSD.org/src/rev/f4f1c1accb64
branches: trunk
changeset: 937757:f4f1c1accb64
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Aug 25 20:49:40 2020 +0000
description:
make(1): move test for the ::= modifier to varmod-assign
diffstat:
usr.bin/make/unit-tests/moderrs.exp | 7 -------
usr.bin/make/unit-tests/moderrs.mk | 9 +--------
usr.bin/make/unit-tests/varmod-assign.exp | 10 ++++++++++
usr.bin/make/unit-tests/varmod-assign.mk | 25 ++++++++++++++++++++++++-
4 files changed, 35 insertions(+), 16 deletions(-)
diffs (107 lines):
diff -r ef73f51ee684 -r f4f1c1accb64 usr.bin/make/unit-tests/moderrs.exp
--- a/usr.bin/make/unit-tests/moderrs.exp Tue Aug 25 20:02:33 2020 +0000
+++ b/usr.bin/make/unit-tests/moderrs.exp Tue Aug 25 20:49:40 2020 +0000
@@ -123,13 +123,6 @@
make: Unfinished modifier for FIB ('}' missing)
then
-mod-assign-parse:
-make: Unknown modifier ':'
-
-make: Bad modifier `:' for
-value}
-make: Unfinished modifier for ASSIGN ('}' missing)
-
mod-remember-parse:
1 1 2 3 5 8 13 21 34
make: Unknown modifier '_'
diff -r ef73f51ee684 -r f4f1c1accb64 usr.bin/make/unit-tests/moderrs.mk
--- a/usr.bin/make/unit-tests/moderrs.mk Tue Aug 25 20:02:33 2020 +0000
+++ b/usr.bin/make/unit-tests/moderrs.mk Tue Aug 25 20:49:40 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: moderrs.mk,v 1.14 2020/08/09 15:15:29 rillig Exp $
+# $Id: moderrs.mk,v 1.15 2020/08/25 20:49:40 rillig Exp $
#
# various modifier error tests
@@ -20,7 +20,6 @@
all: mod-ts-parse
all: mod-t-parse
all: mod-ifelse-parse
-all: mod-assign-parse
all: mod-remember-parse
all: mod-sysv-parse
@@ -164,12 +163,6 @@
@echo ${FIB:?then:else
@echo ${FIB:?then:else}
-mod-assign-parse:
- @echo $@:
- @echo ${ASSIGN::x} # 'x' is an unknown assignment operator
- @echo ${::=value} # trying to set the empty variable
- @echo ${ASSIGN::=value # missing closing brace
-
mod-remember-parse:
@echo $@:
@echo ${FIB:_} # ok
diff -r ef73f51ee684 -r f4f1c1accb64 usr.bin/make/unit-tests/varmod-assign.exp
--- a/usr.bin/make/unit-tests/varmod-assign.exp Tue Aug 25 20:02:33 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-assign.exp Tue Aug 25 20:49:40 2020 +0000
@@ -10,4 +10,14 @@
mod-assign-nested: else2e2
mod-assign-nested: then3t3
mod-assign-nested: else4e4
+make: Bad modifier `:' for
+value}
+make: Bad modifier `:' for
+mod-assign-empty: overwritten}
+mod-assign-empty: VAR=overwritten
+make: Unknown modifier ':'
+
+sysv:y
+make: Unfinished modifier for ASSIGN ('}' missing)
+
exit status 0
diff -r ef73f51ee684 -r f4f1c1accb64 usr.bin/make/unit-tests/varmod-assign.mk
--- a/usr.bin/make/unit-tests/varmod-assign.mk Tue Aug 25 20:02:33 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-assign.mk Tue Aug 25 20:49:40 2020 +0000
@@ -1,10 +1,12 @@
-# $NetBSD: varmod-assign.mk,v 1.3 2020/08/25 18:59:30 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.4 2020/08/25 20:49:40 rillig Exp $
#
# Tests for the obscure ::= variable modifiers, which perform variable
# assignments during evaluation, just like the = operator in C.
all: mod-assign
all: mod-assign-nested
+all: mod-assign-empty
+all: mod-assign-parse
mod-assign:
# The ::?= modifier applies the ?= assignment operator 3 times.
@@ -46,3 +48,24 @@
@echo $@: ${SINK4:Q}
SINK3:= ${1:?${THEN3::=then3${IT3::=t3}}:${ELSE3::=else3${IE3::=e3}}}${THEN3}${ELSE3}${IT3}${IE3}
SINK4:= ${0:?${THEN4::=then4${IT4::=t4}}:${ELSE4::=else4${IE4::=e4}}}${THEN4}${ELSE4}${IT4}${IE4}
+
+mod-assign-empty:
+ # Assigning to the empty variable would obviously not work since that variable
+ # is write-protected. Therefore it is rejected early as a "bad modifier".
+ @echo ${::=value}
+ @echo $@: ${:Uvalue::=overwritten}
+
+ # The :L modifier sets the variable's value to its name.
+ # Since the name is still "VAR", assigning to that variable works.
+ @echo $@: ${VAR:L::=overwritten} VAR=${VAR}
+
+mod-assign-parse:
+ # The modifier for assignment operators starts with a ':'.
+ # An 'x' after that is an invalid modifier.
+ @echo ${ASSIGN::x} # 'x' is an unknown assignment operator
+
+ # When parsing an assignment operator fails because the operator is
+ # incomplete, make falls back to the SysV modifier.
+ @echo ${SYSV::=sysv\:x}${SYSV::x=:y}
+
+ @echo ${ASSIGN::=value # missing closing brace
Home |
Main Index |
Thread Index |
Old Index