Tue Aug 25 20:49:40 2020 UTC ()
make(1): move test for the ::= modifier to varmod-assign


(rillig)
diff -r1.15 -r1.16 src/usr.bin/make/unit-tests/moderrs.exp
diff -r1.14 -r1.15 src/usr.bin/make/unit-tests/moderrs.mk
diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-assign.exp
diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-assign.mk

cvs diff -r1.15 -r1.16 src/usr.bin/make/unit-tests/moderrs.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/moderrs.exp 2020/08/09 15:15:29 1.15
+++ src/usr.bin/make/unit-tests/moderrs.exp 2020/08/25 20:49:40 1.16
@@ -113,33 +113,26 @@ make: Bad modifier `:t' for FIB @@ -113,33 +113,26 @@ make: Bad modifier `:t' for FIB
113 113
114make: Bad modifier `:t' for FIB 114make: Bad modifier `:t' for FIB
115M*} 115M*}
116mod-ifelse-parse: 116mod-ifelse-parse:
117make: Unfinished modifier for FIB (':' missing) 117make: Unfinished modifier for FIB (':' missing)
118 118
119make: Unfinished modifier for FIB (':' missing) 119make: Unfinished modifier for FIB (':' missing)
120 120
121make: Unfinished modifier for FIB ('}' missing) 121make: Unfinished modifier for FIB ('}' missing)
122 122
123make: Unfinished modifier for FIB ('}' missing) 123make: Unfinished modifier for FIB ('}' missing)
124 124
125then 125then
126mod-assign-parse: 
127make: Unknown modifier ':' 
128 
129make: Bad modifier `:' for  
130value} 
131make: Unfinished modifier for ASSIGN ('}' missing) 
132 
133mod-remember-parse: 126mod-remember-parse:
1341 1 2 3 5 8 13 21 34 1271 1 2 3 5 8 13 21 34
135make: Unknown modifier '_' 128make: Unknown modifier '_'
136 129
137mod-sysv-parse: 130mod-sysv-parse:
138make: Unknown modifier '3' 131make: Unknown modifier '3'
139make: Unclosed variable specification (expecting '}') for "FIB" (value "") modifier 3 132make: Unclosed variable specification (expecting '}') for "FIB" (value "") modifier 3
140 133
141make: Unknown modifier '3' 134make: Unknown modifier '3'
142make: Unclosed variable specification (expecting '}') for "FIB" (value "") modifier 3 135make: Unclosed variable specification (expecting '}') for "FIB" (value "") modifier 3
143 136
144make: Unknown modifier '3' 137make: Unknown modifier '3'
145make: Unclosed variable specification (expecting '}') for "FIB" (value "") modifier 3 138make: Unclosed variable specification (expecting '}') for "FIB" (value "") modifier 3

cvs diff -r1.14 -r1.15 src/usr.bin/make/unit-tests/moderrs.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/moderrs.mk 2020/08/09 15:15:29 1.14
+++ src/usr.bin/make/unit-tests/moderrs.mk 2020/08/25 20:49:40 1.15
@@ -1,36 +1,35 @@ @@ -1,36 +1,35 @@
1# $Id: moderrs.mk,v 1.14 2020/08/09 15:15:29 rillig Exp $ 1# $Id: moderrs.mk,v 1.15 2020/08/25 20:49:40 rillig Exp $
2# 2#
3# various modifier error tests 3# various modifier error tests
4 4
5VAR=TheVariable 5VAR=TheVariable
6# incase we have to change it ;-) 6# incase we have to change it ;-)
7MOD_UNKN=Z 7MOD_UNKN=Z
8MOD_TERM=S,V,v 8MOD_TERM=S,V,v
9MOD_S:= ${MOD_TERM}, 9MOD_S:= ${MOD_TERM},
10 10
11FIB= 1 1 2 3 5 8 13 21 34 11FIB= 1 1 2 3 5 8 13 21 34
12 12
13all: modunkn modunknV varterm vartermV modtermV modloop 13all: modunkn modunknV varterm vartermV modtermV modloop
14all: modloop-close 14all: modloop-close
15all: modwords 15all: modwords
16all: modexclam 16all: modexclam
17all: mod-subst-delimiter 17all: mod-subst-delimiter
18all: mod-regex-delimiter 18all: mod-regex-delimiter
19all: mod-regex-undefined-subexpression 19all: mod-regex-undefined-subexpression
20all: mod-ts-parse 20all: mod-ts-parse
21all: mod-t-parse 21all: mod-t-parse
22all: mod-ifelse-parse 22all: mod-ifelse-parse
23all: mod-assign-parse 
24all: mod-remember-parse 23all: mod-remember-parse
25all: mod-sysv-parse 24all: mod-sysv-parse
26 25
27modunkn: 26modunkn:
28 @echo "Expect: Unknown modifier 'Z'" 27 @echo "Expect: Unknown modifier 'Z'"
29 @echo "VAR:Z=${VAR:Z}" 28 @echo "VAR:Z=${VAR:Z}"
30 29
31modunknV: 30modunknV:
32 @echo "Expect: Unknown modifier 'Z'" 31 @echo "Expect: Unknown modifier 'Z'"
33 @echo "VAR:${MOD_UNKN}=${VAR:${MOD_UNKN}}" 32 @echo "VAR:${MOD_UNKN}=${VAR:${MOD_UNKN}}"
34 33
35varterm: 34varterm:
36 @echo "Expect: Unclosed variable specification for VAR" 35 @echo "Expect: Unclosed variable specification for VAR"
@@ -154,30 +153,24 @@ mod-t-parse: @@ -154,30 +153,24 @@ mod-t-parse:
154 @echo ${FIB:t 153 @echo ${FIB:t
155 @echo ${FIB:txy} 154 @echo ${FIB:txy}
156 @echo ${FIB:t} 155 @echo ${FIB:t}
157 @echo ${FIB:t:M*} 156 @echo ${FIB:t:M*}
158 157
159mod-ifelse-parse: 158mod-ifelse-parse:
160 @echo $@: 159 @echo $@:
161 @echo ${FIB:? 160 @echo ${FIB:?
162 @echo ${FIB:?then 161 @echo ${FIB:?then
163 @echo ${FIB:?then: 162 @echo ${FIB:?then:
164 @echo ${FIB:?then:else 163 @echo ${FIB:?then:else
165 @echo ${FIB:?then:else} 164 @echo ${FIB:?then:else}
166 165
167mod-assign-parse: 
168 @echo $@: 
169 @echo ${ASSIGN::x} # 'x' is an unknown assignment operator 
170 @echo ${::=value} # trying to set the empty variable 
171 @echo ${ASSIGN::=value # missing closing brace 
172 
173mod-remember-parse: 166mod-remember-parse:
174 @echo $@: 167 @echo $@:
175 @echo ${FIB:_} # ok 168 @echo ${FIB:_} # ok
176 @echo ${FIB:__} # modifier name too long 169 @echo ${FIB:__} # modifier name too long
177 170
178mod-sysv-parse: 171mod-sysv-parse:
179 @echo $@: 172 @echo $@:
180 @echo ${FIB:3 173 @echo ${FIB:3
181 @echo ${FIB:3= 174 @echo ${FIB:3=
182 @echo ${FIB:3=x3 175 @echo ${FIB:3=x3
183 @echo ${FIB:3=x3} # ok 176 @echo ${FIB:3=x3} # ok

cvs diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-assign.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmod-assign.exp 2020/08/16 12:48:55 1.2
+++ src/usr.bin/make/unit-tests/varmod-assign.exp 2020/08/25 20:49:40 1.3
@@ -1,13 +1,23 @@ @@ -1,13 +1,23 @@
1mod-assign: first=1. 1mod-assign: first=1.
2mod-assign: last=3. 2mod-assign: last=3.
3mod-assign: appended=1 2 3. 3mod-assign: appended=1 2 3.
41 41
52 52
63 63
7mod-assign: ran:3. 7mod-assign: ran:3.
8mod-assign: global: 1, 3, 1 2 3, 3. 8mod-assign: global: 1, 3, 1 2 3, 3.
9mod-assign-nested: then1t1 9mod-assign-nested: then1t1
10mod-assign-nested: else2e2 10mod-assign-nested: else2e2
11mod-assign-nested: then3t3 11mod-assign-nested: then3t3
12mod-assign-nested: else4e4 12mod-assign-nested: else4e4
 13make: Bad modifier `:' for
 14value}
 15make: Bad modifier `:' for
 16mod-assign-empty: overwritten}
 17mod-assign-empty: VAR=overwritten
 18make: Unknown modifier ':'
 19
 20sysv:y
 21make: Unfinished modifier for ASSIGN ('}' missing)
 22
13exit status 0 23exit status 0

cvs diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-assign.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmod-assign.mk 2020/08/25 18:59:30 1.3
+++ src/usr.bin/make/unit-tests/varmod-assign.mk 2020/08/25 20:49:40 1.4
@@ -1,20 +1,22 @@ @@ -1,20 +1,22 @@
1# $NetBSD: varmod-assign.mk,v 1.3 2020/08/25 18:59:30 rillig Exp $ 1# $NetBSD: varmod-assign.mk,v 1.4 2020/08/25 20:49:40 rillig Exp $
2# 2#
3# Tests for the obscure ::= variable modifiers, which perform variable 3# Tests for the obscure ::= variable modifiers, which perform variable
4# assignments during evaluation, just like the = operator in C. 4# assignments during evaluation, just like the = operator in C.
5 5
6all: mod-assign 6all: mod-assign
7all: mod-assign-nested 7all: mod-assign-nested
 8all: mod-assign-empty
 9all: mod-assign-parse
8 10
9mod-assign: 11mod-assign:
10 # The ::?= modifier applies the ?= assignment operator 3 times. 12 # The ::?= modifier applies the ?= assignment operator 3 times.
11 # The ?= operator only has an effect for the first time, therefore 13 # The ?= operator only has an effect for the first time, therefore
12 # the variable FIRST ends up with the value 1. 14 # the variable FIRST ends up with the value 1.
13 @echo $@: ${1 2 3:L:@i@${FIRST::?=$i}@} first=${FIRST}. 15 @echo $@: ${1 2 3:L:@i@${FIRST::?=$i}@} first=${FIRST}.
14 16
15 # The ::= modifier applies the = assignment operator 3 times. 17 # The ::= modifier applies the = assignment operator 3 times.
16 # The = operator overwrites the previous value, therefore the 18 # The = operator overwrites the previous value, therefore the
17 # variable LAST ends up with the value 3. 19 # variable LAST ends up with the value 3.
18 @echo $@: ${1 2 3:L:@i@${LAST::=$i}@} last=${LAST}. 20 @echo $@: ${1 2 3:L:@i@${LAST::=$i}@} last=${LAST}.
19 21
20 # The ::+= modifier applies the += assignment operator 3 times. 22 # The ::+= modifier applies the += assignment operator 3 times.
@@ -36,13 +38,34 @@ mod-assign-nested: @@ -36,13 +38,34 @@ mod-assign-nested:
36 # The condition "1" is true, therefore THEN1 gets assigned a value, 38 # The condition "1" is true, therefore THEN1 gets assigned a value,
37 # and IT1 as well. Nothing surprising here. 39 # and IT1 as well. Nothing surprising here.
38 @echo $@: ${1:?${THEN1::=then1${IT1::=t1}}:${ELSE1::=else1${IE1::=e1}}}${THEN1}${ELSE1}${IT1}${IE1} 40 @echo $@: ${1:?${THEN1::=then1${IT1::=t1}}:${ELSE1::=else1${IE1::=e1}}}${THEN1}${ELSE1}${IT1}${IE1}
39 41
40 # The condition "0" is false, therefore ELSE1 gets assigned a value, 42 # The condition "0" is false, therefore ELSE1 gets assigned a value,
41 # and IE1 as well. Nothing surprising here as well. 43 # and IE1 as well. Nothing surprising here as well.
42 @echo $@: ${0:?${THEN2::=then2${IT2::=t2}}:${ELSE2::=else2${IE2::=e2}}}${THEN2}${ELSE2}${IT2}${IE2} 44 @echo $@: ${0:?${THEN2::=then2${IT2::=t2}}:${ELSE2::=else2${IE2::=e2}}}${THEN2}${ELSE2}${IT2}${IE2}
43 45
44 # The same effects happen when the variables are defined elsewhere. 46 # The same effects happen when the variables are defined elsewhere.
45 @echo $@: ${SINK3:Q} 47 @echo $@: ${SINK3:Q}
46 @echo $@: ${SINK4:Q} 48 @echo $@: ${SINK4:Q}
47SINK3:= ${1:?${THEN3::=then3${IT3::=t3}}:${ELSE3::=else3${IE3::=e3}}}${THEN3}${ELSE3}${IT3}${IE3} 49SINK3:= ${1:?${THEN3::=then3${IT3::=t3}}:${ELSE3::=else3${IE3::=e3}}}${THEN3}${ELSE3}${IT3}${IE3}
48SINK4:= ${0:?${THEN4::=then4${IT4::=t4}}:${ELSE4::=else4${IE4::=e4}}}${THEN4}${ELSE4}${IT4}${IE4} 50SINK4:= ${0:?${THEN4::=then4${IT4::=t4}}:${ELSE4::=else4${IE4::=e4}}}${THEN4}${ELSE4}${IT4}${IE4}
 51
 52mod-assign-empty:
 53 # Assigning to the empty variable would obviously not work since that variable
 54 # is write-protected. Therefore it is rejected early as a "bad modifier".
 55 @echo ${::=value}
 56 @echo $@: ${:Uvalue::=overwritten}
 57
 58 # The :L modifier sets the variable's value to its name.
 59 # Since the name is still "VAR", assigning to that variable works.
 60 @echo $@: ${VAR:L::=overwritten} VAR=${VAR}
 61
 62mod-assign-parse:
 63 # The modifier for assignment operators starts with a ':'.
 64 # An 'x' after that is an invalid modifier.
 65 @echo ${ASSIGN::x} # 'x' is an unknown assignment operator
 66
 67 # When parsing an assignment operator fails because the operator is
 68 # incomplete, make falls back to the SysV modifier.
 69 @echo ${SYSV::=sysv\:x}${SYSV::x=:y}
 70
 71 @echo ${ASSIGN::=value # missing closing brace