Module Name: src
Committed By: rillig
Date: Sun Dec 17 23:19:02 UTC 2023
Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp varmod-match.mk
Log Message:
tests/make: test the fast code path for ':M' patterns like '*.c'
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmod-match.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/unit-tests/varmod-match.exp
diff -u src/usr.bin/make/unit-tests/varmod-match.exp:1.13 src/usr.bin/make/unit-tests/varmod-match.exp:1.14
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.13 Sun Dec 17 00:19:11 2023
+++ src/usr.bin/make/unit-tests/varmod-match.exp Sun Dec 17 23:19:02 2023
@@ -1,14 +1,14 @@
-make: "varmod-match.mk" line 268: warning: Unfinished character list in pattern 'a[' of modifier ':M'
-make: "varmod-match.mk" line 276: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
-make: "varmod-match.mk" line 284: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 292: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 301: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 315: warning: Unfinished character list in pattern '?[\' of modifier ':M'
-make: "varmod-match.mk" line 323: warning: Unfinished character range in pattern '[x-' of modifier ':M'
-make: "varmod-match.mk" line 335: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
-make: "varmod-match.mk" line 343: warning: Unfinished character list in pattern '[' of modifier ':M'
-make: "varmod-match.mk" line 343: Unknown modifier "]"
-make: "varmod-match.mk" line 343: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
+make: "varmod-match.mk" line 289: warning: Unfinished character list in pattern 'a[' of modifier ':M'
+make: "varmod-match.mk" line 297: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
+make: "varmod-match.mk" line 305: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 313: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 322: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 336: warning: Unfinished character list in pattern '?[\' of modifier ':M'
+make: "varmod-match.mk" line 344: warning: Unfinished character range in pattern '[x-' of modifier ':M'
+make: "varmod-match.mk" line 356: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
+make: "varmod-match.mk" line 364: warning: Unfinished character list in pattern '[' of modifier ':M'
+make: "varmod-match.mk" line 364: Unknown modifier "]"
+make: "varmod-match.mk" line 364: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/varmod-match.mk
diff -u src/usr.bin/make/unit-tests/varmod-match.mk:1.19 src/usr.bin/make/unit-tests/varmod-match.mk:1.20
--- src/usr.bin/make/unit-tests/varmod-match.mk:1.19 Sun Dec 17 00:19:11 2023
+++ src/usr.bin/make/unit-tests/varmod-match.mk Sun Dec 17 23:19:02 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-match.mk,v 1.19 2023/12/17 00:19:11 rillig Exp $
+# $NetBSD: varmod-match.mk,v 1.20 2023/12/17 23:19:02 rillig Exp $
#
# Tests for the ':M' modifier, which keeps only those words that match the
# given pattern.
@@ -53,6 +53,27 @@
. error
.endif
+# Test the fast code path for '*' followed by a regular character.
+.if ${:U file.c file.*c file.h file\.c :M*.c} != "file.c file\\.c"
+. error
+.endif
+# Ensure that the fast code path correctly handles the backslash.
+.if ${:U file.c file.*c file.h file\.c :M*\.c} != "file.c file\\.c"
+. error
+.endif
+# Ensure that the fast code path correctly handles '\*'.
+.if ${:U file.c file.*c file.h file\.c :M*\*c} != "file.*c"
+. error
+.endif
+# Ensure that the partial match '.c' doesn't confuse the fast code path.
+.if ${:U file.c.cc file.cc.cc file.cc.c :M*.cc} != "file.c.cc file.cc.cc"
+. error
+.endif
+# Ensure that the substring '.cc' doesn't confuse the fast code path for '.c'.
+.if ${:U file.c.cc file.cc.cc file.cc.c :M*.c} != "file.cc.c"
+. error
+.endif
+
# 2. Character lists and character ranges
#