Sat Aug 1 15:16:15 2020 UTC ()
make(1): add test for ${VAR::::}

It's a bit unrealistic, but at least there are good diagnostics.


(rillig)
diff -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-edge.exp
diff -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-edge.mk

cvs diff -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-edge.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmod-edge.exp 2020/08/01 15:13:45 1.5
+++ src/usr.bin/make/unit-tests/varmod-edge.exp 2020/08/01 15:16:15 1.6
@@ -1,18 +1,21 @@ @@ -1,18 +1,21 @@
1make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U 1make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U
2make: Unclosed substitution for INP.eq-esc (= missing) 2make: Unclosed substitution for INP.eq-esc (= missing)
 3make: Unknown modifier ':'
 4make: Unknown modifier ':'
3ok M-paren 5ok M-paren
4ok M-mixed 6ok M-mixed
5ok M-unescape 7ok M-unescape
6ok M-nest-mix 8ok M-nest-mix
7ok M-nest-brk 9ok M-nest-brk
8ok M-pat-err 10ok M-pat-err
9ok M-bsbs 11ok M-bsbs
10ok M-bs1-par 12ok M-bs1-par
11ok M-bs2-par 13ok M-bs2-par
12ok M-128 14ok M-128
13ok eq-ext 15ok eq-ext
14ok eq-q 16ok eq-q
15ok eq-bs 17ok eq-bs
16ok eq-esc 18ok eq-esc
17ok colon 19ok colon
 20ok colons
18exit status 0 21exit status 0

cvs diff -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-edge.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmod-edge.mk 2020/08/01 15:13:45 1.9
+++ src/usr.bin/make/unit-tests/varmod-edge.mk 2020/08/01 15:16:15 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: varmod-edge.mk,v 1.9 2020/08/01 15:13:45 rillig Exp $ 1# $NetBSD: varmod-edge.mk,v 1.10 2020/08/01 15:16:15 rillig Exp $
2# 2#
3# Tests for edge cases in variable modifiers. 3# Tests for edge cases in variable modifiers.
4# 4#
5# These tests demonstrate the current implementation in small examples. 5# These tests demonstrate the current implementation in small examples.
6# They may contain surprising behavior. 6# They may contain surprising behavior.
7# 7#
8# Each test consists of: 8# Each test consists of:
9# - INP, the input to the test 9# - INP, the input to the test
10# - MOD, the expression for testing the modifier 10# - MOD, the expression for testing the modifier
11# - EXP, the expected output 11# - EXP, the expected output
12 12
13TESTS+= M-paren 13TESTS+= M-paren
14INP.M-paren= (parentheses) {braces} (opening closing) () 14INP.M-paren= (parentheses) {braces} (opening closing) ()
@@ -146,22 +146,27 @@ EXP.eq-bs= file.c file.ext @@ -146,22 +146,27 @@ EXP.eq-bs= file.c file.ext
146# Having only an escaped '=' results in a parse error. 146# Having only an escaped '=' results in a parse error.
147# The call to "pattern.lhs = ParseModifierPart" fails. 147# The call to "pattern.lhs = ParseModifierPart" fails.
148TESTS+= eq-esc 148TESTS+= eq-esc
149INP.eq-esc= file.c file... 149INP.eq-esc= file.c file...
150MOD.eq-esc= ${INP.eq-esc:a\=b} 150MOD.eq-esc= ${INP.eq-esc:a\=b}
151EXP.eq-esc= # empty 151EXP.eq-esc= # empty
152# make: Unclosed substitution for INP.eq-esc (= missing) 152# make: Unclosed substitution for INP.eq-esc (= missing)
153 153
154TESTS+= colon 154TESTS+= colon
155INP.colon= value 155INP.colon= value
156MOD.colon= ${INP.colon:} 156MOD.colon= ${INP.colon:}
157EXP.colon= value 157EXP.colon= value
158 158
 159TESTS+= colons
 160INP.colons= value
 161MOD.colons= ${INP.colons::::}
 162EXP.colons= # empty
 163
159all: 164all:
160.for test in ${TESTS} 165.for test in ${TESTS}
161. if ${MOD.${test}} == ${EXP.${test}} 166. if ${MOD.${test}} == ${EXP.${test}}
162 @printf 'ok %s\n' ${test:Q}'' 167 @printf 'ok %s\n' ${test:Q}''
163. else 168. else
164 @printf 'error in %s: expected %s, got %s\n' \ 169 @printf 'error in %s: expected %s, got %s\n' \
165 ${test:Q}'' ${EXP.${test}:Q}'' ${MOD.${test}:Q}'' 170 ${test:Q}'' ${EXP.${test}:Q}'' ${MOD.${test}:Q}''
166. endif 171. endif
167.endfor 172.endfor