Sun Nov 1 13:28:50 2020 UTC ()
make(1): add tests for parsing errors in the :ts variable modifier


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

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

--- src/usr.bin/make/unit-tests/varmod-to-separator.exp 2020/11/01 11:50:11 1.3
+++ src/usr.bin/make/unit-tests/varmod-to-separator.exp 2020/11/01 13:28:50 1.4
@@ -1,11 +1,17 @@ @@ -1,11 +1,17 @@
1make: "varmod-to-separator.mk" line 106: warning: The separator \400 is accepted even though it is out of bounds. 1make: "varmod-to-separator.mk" line 106: warning: The separator \400 is accepted even though it is out of bounds.
2make: "varmod-to-separator.mk" line 118: warning: The separator \x100 is accepted even though it is out of bounds. 2make: "varmod-to-separator.mk" line 118: warning: The separator \x100 is accepted even though it is out of bounds.
 3make: Bad modifier `:ts\-300' for WORDS
 4make: "varmod-to-separator.mk" line 124: Malformed conditional (${WORDS:[1..3]:ts\-300:tu})
 5make: Bad modifier `:ts\8' for 1 2 3
 6make: "varmod-to-separator.mk" line 132: Malformed conditional (${1 2 3:L:ts\8:tu})
 7make: Bad modifier `:ts\100L' for 1 2 3
 8make: "varmod-to-separator.mk" line 139: Malformed conditional (${1 2 3:L:ts\100L})
 9make: Bad modifier `:ts\x40g' for 1 2 3
 10make: "varmod-to-separator.mk" line 146: Malformed conditional (${1 2 3:L:ts\x40g})
3make: Bad modifier `:tx' for WORDS 11make: Bad modifier `:tx' for WORDS
4make: "varmod-to-separator.mk" line 124: Malformed conditional (${WORDS:tx} != "anything") 12make: "varmod-to-separator.mk" line 154: Malformed conditional (${WORDS:tx} != "anything")
5make: "varmod-to-separator.mk" line 128: Parsing continues here. 
6make: Bad modifier `:t\X' for WORDS 13make: Bad modifier `:t\X' for WORDS
7make: "varmod-to-separator.mk" line 132: Malformed conditional (${WORDS:t\X} != "anything") 14make: "varmod-to-separator.mk" line 161: Malformed conditional (${WORDS:t\X} != "anything")
8make: "varmod-to-separator.mk" line 135: Parsing continues here. 
9make: Fatal errors encountered -- cannot continue 15make: Fatal errors encountered -- cannot continue
10make: stopped in unit-tests 16make: stopped in unit-tests
11exit status 1 17exit status 1

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

--- src/usr.bin/make/unit-tests/varmod-to-separator.mk 2020/11/01 11:50:11 1.4
+++ src/usr.bin/make/unit-tests/varmod-to-separator.mk 2020/11/01 13:28:50 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: varmod-to-separator.mk,v 1.4 2020/11/01 11:50:11 rillig Exp $ 1# $NetBSD: varmod-to-separator.mk,v 1.5 2020/11/01 13:28:50 rillig Exp $
2# 2#
3# Tests for the :ts variable modifier, which joins the words of the variable 3# Tests for the :ts variable modifier, which joins the words of the variable
4# using an arbitrary character as word separator. 4# using an arbitrary character as word separator.
5 5
6WORDS= one two three four five six 6WORDS= one two three four five six
7 7
8# The words are separated by a single space, just as usual. 8# The words are separated by a single space, just as usual.
9.if ${WORDS:ts } != "one two three four five six" 9.if ${WORDS:ts } != "one two three four five six"
10. warning Space as separator does not work. 10. warning Space as separator does not work.
11.endif 11.endif
12 12
13# The separator can be an arbitrary character, for example a comma. 13# The separator can be an arbitrary character, for example a comma.
14.if ${WORDS:ts,} != "one,two,three,four,five,six" 14.if ${WORDS:ts,} != "one,two,three,four,five,six"
@@ -110,29 +110,56 @@ WORDS= one two three four five six @@ -110,29 +110,56 @@ WORDS= one two three four five six
110 110
111# The separator can be given as hexadecimal number. 111# The separator can be given as hexadecimal number.
112.if ${WORDS:[1..3]:ts\xa:tu} != "ONE${.newline}TWO${.newline}THREE" 112.if ${WORDS:[1..3]:ts\xa:tu} != "ONE${.newline}TWO${.newline}THREE"
113. warning The separator \xa is not interpreted in hexadecimal ASCII. 113. warning The separator \xa is not interpreted in hexadecimal ASCII.
114.endif 114.endif
115 115
116# The hexadecimal number must be in the range of an unsigned char. 116# The hexadecimal number must be in the range of an unsigned char.
117.if ${WORDS:[1..3]:ts\x100:tu} 117.if ${WORDS:[1..3]:ts\x100:tu}
118. warning The separator \x100 is accepted even though it is out of bounds. 118. warning The separator \x100 is accepted even though it is out of bounds.
119.else 119.else
120. warning The separator \x100 is accepted even though it is out of bounds. 120. warning The separator \x100 is accepted even though it is out of bounds.
121.endif 121.endif
122 122
 123# Negative numbers are not allowed for the separator character.
 124.if ${WORDS:[1..3]:ts\-300:tu}
 125. warning The separator \-300 is accepted even though it is negative.
 126.else
 127. warning The separator \-300 is accepted even though it is negative.
 128.endif
 129
 130# The character number is interpreted as octal number by default.
 131# The digit '8' is not an octal digit though.
 132.if ${1 2 3:L:ts\8:tu}
 133. warning The separator \8 is accepted even though it is not octal.
 134.else
 135. warning The separator \8 is accepted even though it is not octal.
 136.endif
 137
 138# Trailing characters after the octal character number are rejected.
 139.if ${1 2 3:L:ts\100L}
 140. warning The separator \100L is accepted even though it contains an 'L'.
 141.else
 142. warning The separator \100L is accepted even though it contains an 'L'.
 143.endif
 144
 145# Trailing characters after the hexadecimal character number are rejected.
 146.if ${1 2 3:L:ts\x40g}
 147. warning The separator \x40g is accepted even though it contains a 'g'.
 148.else
 149. warning The separator \x40g is accepted even though it contains a 'g'.
 150.endif
 151
 152
123# In the :t modifier, the :t must be followed by any of A, l, s, u. 153# In the :t modifier, the :t must be followed by any of A, l, s, u.
124.if ${WORDS:tx} != "anything" 154.if ${WORDS:tx} != "anything"
125. info This line is not reached because of the malformed condition. 155. info This line is not reached because of the malformed condition.
126. info If this line were reached, it would be visible in the -dcpv log. 156. info If this line were reached, it would be visible in the -dcpv log.
127.endif 157.endif
128.info Parsing continues here. 
129 158
130# After the backslash, only n, t, an octal number, or x and a hexadecimal 159# After the backslash, only n, t, an octal number, or x and a hexadecimal
131# number are allowed. 160# number are allowed.
132.if ${WORDS:t\X} != "anything" 161.if ${WORDS:t\X} != "anything"
133. info This line is not reached. 162. info This line is not reached.
134.endif 163.endif
135.info Parsing continues here. 
136 164
137all: 165all:
138 @:;