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 (expand / 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
@@ -16,14 +16,19 @@ VAR:S,V,v= @@ -16,14 +16,19 @@ VAR: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 (expand / 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,25 +1,26 @@ @@ -1,25 +1,26 @@
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
@@ -47,13 +48,22 @@ modwords: @@ -47,13 +48,22 @@ modwords:
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}