Fri Oct 30 14:46:01 2020 UTC ()
make(1): add more test cases that fail in condition string literals


(rillig)
diff -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-cmp-string.exp
diff -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-cmp-string.mk

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

--- src/usr.bin/make/unit-tests/cond-cmp-string.exp 2020/10/30 08:13:17 1.5
+++ src/usr.bin/make/unit-tests/cond-cmp-string.exp 2020/10/30 14:46:01 1.6
@@ -1,9 +1,11 @@ @@ -1,9 +1,11 @@
1make: "cond-cmp-string.mk" line 18: Malformed conditional (str != str) 1make: "cond-cmp-string.mk" line 18: Malformed conditional (str != str)
2make: "cond-cmp-string.mk" line 37: Malformed conditional ("string" != "str""ing") 2make: "cond-cmp-string.mk" line 37: Malformed conditional ("string" != "str""ing")
3make: "cond-cmp-string.mk" line 42: warning: String comparison operator must be either == or != 3make: "cond-cmp-string.mk" line 42: warning: String comparison operator must be either == or !=
4make: "cond-cmp-string.mk" line 42: Malformed conditional (!("value" = "value")) 4make: "cond-cmp-string.mk" line 42: Malformed conditional (!("value" = "value"))
5make: "cond-cmp-string.mk" line 49: Malformed conditional (!("value" === "value")) 5make: "cond-cmp-string.mk" line 49: Malformed conditional (!("value" === "value"))
6make: "cond-cmp-string.mk" line 63: Malformed conditional (${:Uword} != "${:Uword} ") 6make: "cond-cmp-string.mk" line 63: Malformed conditional (${:Uword} != "${:Uword} ")
 7make: "cond-cmp-string.mk" line 77: Malformed conditional (${:Uword!} != "${:Uword}!")
 8make: "cond-cmp-string.mk" line 80: Malformed conditional (${:Uword<} != "${:Uword}<")
7make: Fatal errors encountered -- cannot continue 9make: Fatal errors encountered -- cannot continue
8make: stopped in unit-tests 10make: stopped in unit-tests
9exit status 1 11exit status 1

cvs diff -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-cmp-string.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/cond-cmp-string.mk 2020/10/30 13:41:14 1.8
+++ src/usr.bin/make/unit-tests/cond-cmp-string.mk 2020/10/30 14:46:01 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: cond-cmp-string.mk,v 1.8 2020/10/30 13:41:14 rillig Exp $ 1# $NetBSD: cond-cmp-string.mk,v 1.9 2020/10/30 14:46:01 rillig Exp $
2# 2#
3# Tests for string comparisons in .if conditions. 3# Tests for string comparisons in .if conditions.
4 4
5# This is a simple comparison of string literals. 5# This is a simple comparison of string literals.
6# Nothing surprising here. 6# Nothing surprising here.
7.if "str" != "str" 7.if "str" != "str"
8. error 8. error
9.endif 9.endif
10 10
11# The right-hand side of the comparison may be written without quotes. 11# The right-hand side of the comparison may be written without quotes.
12.if "str" != str 12.if "str" != str
13. error 13. error
14.endif 14.endif
@@ -56,23 +56,38 @@ @@ -56,23 +56,38 @@
56.if ${:Uword} != "${:Uword}" 56.if ${:Uword} != "${:Uword}"
57. error 57. error
58.endif 58.endif
59 59
60# XXX: As of 2020-10-30, adding literal characters to the string results 60# XXX: As of 2020-10-30, adding literal characters to the string results
61# in a parse error. This is a bug and should have been caught much earlier. 61# in a parse error. This is a bug and should have been caught much earlier.
62# I wonder since when it exists. 62# I wonder since when it exists.
63.if ${:Uword} != "${:Uword} " 63.if ${:Uword} != "${:Uword} "
64. error 64. error
65.else 65.else
66. error 66. error
67.endif 67.endif
68 68
 69# Some other characters work though, and some don't.
 70# Those that are mentioned in is_separator don't work.
 71.if ${:Uword0} != "${:Uword}0"
 72. error
 73.endif
 74.if ${:Uword&} != "${:Uword}&"
 75. error
 76.endif
 77.if ${:Uword!} != "${:Uword}!"
 78. error
 79.endif
 80.if ${:Uword<} != "${:Uword}<"
 81. error
 82.endif
 83
69# Adding another variable expression to the string literal works though. 84# Adding another variable expression to the string literal works though.
70.if ${:Uword} != "${:Uwo}${:Urd}" 85.if ${:Uword} != "${:Uwo}${:Urd}"
71. error 86. error
72.endif 87.endif
73 88
74# Adding a space at the beginning of the quoted variable expression works 89# Adding a space at the beginning of the quoted variable expression works
75# though. 90# though.
76.if ${:U word } != " ${:Uword} " 91.if ${:U word } != " ${:Uword} "
77. error 92. error
78.endif 93.endif