Sun Jul 26 14:39:46 2020 UTC ()
make(1): add tests for :!...! parse errors


(rillig)
diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/moderrs.exp
diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/moderrs.mk

cvs diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/moderrs.exp (switch to unified diff)

--- src/usr.bin/make/unit-tests/moderrs.exp 2020/07/26 14:16:45 1.4
+++ src/usr.bin/make/unit-tests/moderrs.exp 2020/07/26 14:39:46 1.5
@@ -1,29 +1,34 @@ @@ -1,29 +1,34 @@
1Expect: Unknown modifier 'Z' 1Expect: Unknown modifier 'Z'
2make: Unknown modifier 'Z' 2make: Unknown modifier 'Z'
3VAR:Z= 3VAR:Z=
4Expect: Unknown modifier 'Z' 4Expect: Unknown modifier 'Z'
5make: Unknown modifier 'Z' 5make: Unknown modifier 'Z'
6VAR:Z= 6VAR:Z=
7Expect: Unclosed variable specification for VAR 7Expect: Unclosed variable specification for VAR
8make: Unclosed variable specification (expecting '}') for "VAR" (value "Thevariable") modifier S 8make: Unclosed variable specification (expecting '}') for "VAR" (value "Thevariable") modifier S
9VAR:S,V,v,=Thevariable 9VAR:S,V,v,=Thevariable
10Expect: Unclosed variable specification for VAR 10Expect: Unclosed variable specification for VAR
11make: Unclosed variable specification after complex modifier (expecting '}') for VAR 11make: Unclosed variable specification after complex modifier (expecting '}') for VAR
12VAR:S,V,v,=Thevariable 12VAR:S,V,v,=Thevariable
13Expect: Unclosed substitution for VAR (, missing) 13Expect: Unclosed substitution for VAR (, missing)
14make: Unclosed substitution for VAR (, missing) 14make: Unclosed substitution for VAR (, missing)
15VAR:S,V,v= 15VAR:S,V,v=
16Expect: 2 errors about missing @ delimiter 16Expect: 2 errors about missing @ delimiter
17make: Unclosed substitution for UNDEF (@ missing) 17make: Unclosed substitution for UNDEF (@ missing)
18 18
19make: Unclosed substitution for UNDEF (@ missing) 19make: Unclosed substitution for UNDEF (@ missing)
20 20
211 2 3 211 2 3
22Expect: 2 errors about missing ] delimiter 22Expect: 2 errors about missing ] delimiter
23make: Unclosed substitution for UNDEF (] missing) 23make: Unclosed substitution for UNDEF (] missing)
24 24
25make: Unclosed substitution for UNDEF (] missing) 25make: Unclosed substitution for UNDEF (] missing)
26 26
2713= 2713=
2812345=ok 2812345=ok
 29Expect: 2 errors about missing ! delimiter
 30make: Unclosed substitution for VARNAME (! missing)
 31
 32make: Unclosed substitution for ! (! missing)
 33
29exit status 0 34exit status 0

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

--- src/usr.bin/make/unit-tests/moderrs.mk 2020/07/26 14:16:45 1.3
+++ src/usr.bin/make/unit-tests/moderrs.mk 2020/07/26 14:39:46 1.4
@@ -1,59 +1,69 @@ @@ -1,59 +1,69 @@
1# $Id: moderrs.mk,v 1.3 2020/07/26 14:16:45 rillig Exp $ 1# $Id: moderrs.mk,v 1.4 2020/07/26 14:39:46 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
11all: modunkn modunknV varterm vartermV modtermV modloop 11all: modunkn modunknV varterm vartermV modtermV modloop
12all: modwords 12all: modwords
 13all: modexclam
13 14
14modunkn: 15modunkn:
15 @echo "Expect: Unknown modifier 'Z'" 16 @echo "Expect: Unknown modifier 'Z'"
16 @echo "VAR:Z=${VAR:Z}" 17 @echo "VAR:Z=${VAR:Z}"
17 18
18modunknV: 19modunknV:
19 @echo "Expect: Unknown modifier 'Z'" 20 @echo "Expect: Unknown modifier 'Z'"
20 @echo "VAR:${MOD_UNKN}=${VAR:${MOD_UNKN}}" 21 @echo "VAR:${MOD_UNKN}=${VAR:${MOD_UNKN}}"
21 22
22varterm: 23varterm:
23 @echo "Expect: Unclosed variable specification for VAR" 24 @echo "Expect: Unclosed variable specification for VAR"
24 @echo VAR:S,V,v,=${VAR:S,V,v, 25 @echo VAR:S,V,v,=${VAR:S,V,v,
25 26
26vartermV: 27vartermV:
27 @echo "Expect: Unclosed variable specification for VAR" 28 @echo "Expect: Unclosed variable specification for VAR"
28 @echo VAR:${MOD_TERM},=${VAR:${MOD_S} 29 @echo VAR:${MOD_TERM},=${VAR:${MOD_S}
29 30
30modtermV: 31modtermV:
31 @echo "Expect: Unclosed substitution for VAR (, missing)" 32 @echo "Expect: Unclosed substitution for VAR (, missing)"
32 -@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}" 33 -@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}"
33 34
34modloop: 35modloop:
35 @echo "Expect: 2 errors about missing @ delimiter" 36 @echo "Expect: 2 errors about missing @ delimiter"
36 @echo ${UNDEF:U1 2 3:@var} 37 @echo ${UNDEF:U1 2 3:@var}
37 @echo ${UNDEF:U1 2 3:@var@...} 38 @echo ${UNDEF:U1 2 3:@var@...}
38 @echo ${UNDEF:U1 2 3:@var@${var}@} 39 @echo ${UNDEF:U1 2 3:@var@${var}@}
39 40
40modwords: 41modwords:
41 @echo "Expect: 2 errors about missing ] delimiter" 42 @echo "Expect: 2 errors about missing ] delimiter"
42 @echo ${UNDEF:U1 2 3:[} 43 @echo ${UNDEF:U1 2 3:[}
43 @echo ${UNDEF:U1 2 3:[#} 44 @echo ${UNDEF:U1 2 3:[#}
44 45
45 # out of bounds => empty 46 # out of bounds => empty
46 @echo 13=${UNDEF:U1 2 3:[13]} 47 @echo 13=${UNDEF:U1 2 3:[13]}
47 48
48 # Word index out of bounds. 49 # Word index out of bounds.
49 # 50 #
50 # On LP64I32, strtol returns LONG_MAX, 51 # On LP64I32, strtol returns LONG_MAX,
51 # which is then truncated to int (undefined behavior), 52 # which is then truncated to int (undefined behavior),
52 # typically resulting in -1. 53 # typically resulting in -1.
53 # This -1 is interpreted as "the last word". 54 # This -1 is interpreted as "the last word".
54 # 55 #
55 # On ILP32, strtol returns LONG_MAX, 56 # On ILP32, strtol returns LONG_MAX,
56 # which is a large number. 57 # which is a large number.
57 # This results in a range from LONG_MAX - 1 to 3, 58 # This results in a range from LONG_MAX - 1 to 3,
58 # which is empty. 59 # which is empty.
59 @echo 12345=${UNDEF:U1 2 3:[123451234512345123451234512345]:S,^$,ok,:S,^3$,ok,} 60 @echo 12345=${UNDEF:U1 2 3:[123451234512345123451234512345]:S,^$,ok,:S,^3$,ok,}
 61
 62modexclam:
 63 @echo "Expect: 2 errors about missing ! delimiter"
 64 @echo ${VARNAME:!echo}
 65 # When the final exclamation mark is missing, there is no
 66 # fallback to the SysV substitution modifier.
 67 # If there were a fallback, the output would be "exclam",
 68 # and the above would have produced an "Unknown modifier '!'".
 69 @echo ${!:L:!=exclam}