Module Name:    src
Committed By:   rillig
Date:           Sun Aug 16 20:03:53 UTC 2020

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/usr.bin/make/unit-tests: Makefile modmatch.exp modmatch.mk
            varmod-match.exp varmod-match.mk
Added Files:
        src/usr.bin/make/unit-tests: varmod-match-escape.exp
            varmod-match-escape.mk

Log Message:
make(1): move tests for the :M modifier into separate files

The test for the different escaping has been adjusted to actually show
the different parsing results in the test output.  To do this, it had to
get its own file since it needs the -dv debug flag and specialized
post-processing.


To generate a diff of this commit:
cvs rdiff -u -r1.890 -r1.891 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/modmatch.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/modmatch.mk
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-match-escape.exp \
    src/usr.bin/make/unit-tests/varmod-match-escape.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.2 -r1.3 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/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.890 src/distrib/sets/lists/tests/mi:1.891
--- src/distrib/sets/lists/tests/mi:1.890	Sun Aug 16 12:07:50 2020
+++ src/distrib/sets/lists/tests/mi	Sun Aug 16 20:03:52 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.890 2020/08/16 12:07:50 rillig Exp $
+# $NetBSD: mi,v 1.891 2020/08/16 20:03:52 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4913,6 +4913,8 @@
 ./usr/tests/usr.bin/make/unit-tests/varmod-localtime.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varmod-loop.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varmod-loop.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varmod-match-escape.exp	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varmod-match-escape.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varmod-match.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varmod-match.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varmod-no-match.exp	tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.98 src/usr.bin/make/unit-tests/Makefile:1.99
--- src/usr.bin/make/unit-tests/Makefile:1.98	Sun Aug 16 18:40:13 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sun Aug 16 20:03:53 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.98 2020/08/16 18:40:13 rillig Exp $
+# $NetBSD: Makefile,v 1.99 2020/08/16 20:03:53 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -231,6 +231,7 @@ TESTS+=		varmod-l-name-to-value
 TESTS+=		varmod-localtime
 TESTS+=		varmod-loop
 TESTS+=		varmod-match
+TESTS+=		varmod-match-escape
 TESTS+=		varmod-no-match
 TESTS+=		varmod-order
 TESTS+=		varmod-order-reverse
@@ -313,6 +314,7 @@ FLAGS.lint=		-dL -k
 FLAGS.order=		-j1
 FLAGS.recursive=	-dL
 FLAGS.vardebug=		-k -dv FROM_CMDLINE=
+FLAGS.varmod-match-escape= -dv
 
 # Some tests need extra post-processing.
 SED_CMDS.varmod-subst-regex+= \
@@ -324,7 +326,9 @@ SED_CMDS.varshell+=	-e '/command/s,No su
 # Some tests need an additional round of postprocessing.
 POSTPROC.counter=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
 POSTPROC.vardebug=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
+POSTPROC.varmod-match-escape= ${TOOL_SED} -n -e '/^Pattern/p'
 
+# Some tests reuse other tests, which makes them unnecessarily fragile.
 export-all.rawout: export.mk
 unexport.rawout: export.mk
 unexport-env.rawout: export.mk

Index: src/usr.bin/make/unit-tests/modmatch.exp
diff -u src/usr.bin/make/unit-tests/modmatch.exp:1.3 src/usr.bin/make/unit-tests/modmatch.exp:1.4
--- src/usr.bin/make/unit-tests/modmatch.exp:1.3	Fri Apr 21 22:15:44 2017
+++ src/usr.bin/make/unit-tests/modmatch.exp	Sun Aug 16 20:03:53 2020
@@ -14,7 +14,4 @@ LIB=e X_LIBS:M${LIB${LIB:tu}} is "/tmp/l
 LIB=e X_LIBS:M*/lib${LIB}.a is "/tmp/libe.a"
 LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBE.A"
 Mscanner=OK
-Upper=One Two Three Four
-Lower=five six seven
-nose=One Three five
 exit status 0

Index: src/usr.bin/make/unit-tests/modmatch.mk
diff -u src/usr.bin/make/unit-tests/modmatch.mk:1.7 src/usr.bin/make/unit-tests/modmatch.mk:1.8
--- src/usr.bin/make/unit-tests/modmatch.mk:1.7	Sat Aug  1 18:59:16 2020
+++ src/usr.bin/make/unit-tests/modmatch.mk	Sun Aug 16 20:03:53 2020
@@ -1,4 +1,4 @@
-# $NetBSD: modmatch.mk,v 1.7 2020/08/01 18:59:16 rillig Exp $
+# $NetBSD: modmatch.mk,v 1.8 2020/08/16 20:03:53 rillig Exp $
 #
 # Tests for the :M and :S modifiers.
 
@@ -18,7 +18,7 @@ res = no
 res = OK
 .endif
 
-all:	show-libs check-cclass slow
+all:	show-libs
 
 show-libs:
 	@for x in $X; do ${.MAKE} -f ${MAKEFILE} show LIB=$$x; done
@@ -28,30 +28,3 @@ show:
 	@echo 'LIB=${LIB} X_LIBS:M$${LIB$${LIB:tu}} is "${X_LIBS:M${LIB${LIB:tu}}}"'
 	@echo 'LIB=${LIB} X_LIBS:M*/lib$${LIB}.a is "${X_LIBS:M*/lib${LIB}.a}"'
 	@echo 'LIB=${LIB} X_LIBS:M*/lib$${LIB}.a:tu is "${X_LIBS:M*/lib${LIB}.a:tu}"'
-
-LIST= One Two Three Four five six seven
-
-check-cclass:
-	@echo Upper=${LIST:M[A-Z]*}
-	@echo Lower=${LIST:M[^A-Z]*}
-	@echo nose=${LIST:M[^s]*[ex]}
-
-# Before 2020-06-13, this expression took quite a long time in Str_Match,
-# calling itself 601080390 times for 16 asterisks.
-slow: .PHONY
-	@:;: ${:U****************:M****************b:Q}
-
-# As of 2020-08-01, the :M and :N modifiers interpret backslashes differently,
-# depending on whether there was a variable expression before the first
-# backslash or not.  This can be seen by setting the -dv debug flag, in the
-# lines starting with "Pattern".
-#
-# Apart from the different and possibly confusing debug output, there is no
-# difference in behavior.  When parsing the modifier text, only \{, \} and \:
-# are unescaped, and in the pattern matching these have the same meaning as
-# their plain variants '{', '}' and ':'.  In the pattern matching from
-# Str_Match, only \*, \? or \[ would make a noticeable difference.
-SPECIALS=	\: : \\ * \*
-.if ${SPECIALS:M${:U}\:} != ${SPECIALS:M\:${:U}}
-.warning unexpected
-.endif

Index: src/usr.bin/make/unit-tests/varmod-match.exp
diff -u src/usr.bin/make/unit-tests/varmod-match.exp:1.1 src/usr.bin/make/unit-tests/varmod-match.exp:1.2
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Sun Aug 16 20:03:53 2020
@@ -1 +1,5 @@
+match-char-class:
+  uppercase numbers: One Two Three Four
+  all the others: five six seven
+  starts with non-s, ends with [ex]: One Three five
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-match.mk
diff -u src/usr.bin/make/unit-tests/varmod-match.mk:1.2 src/usr.bin/make/unit-tests/varmod-match.mk:1.3
--- src/usr.bin/make/unit-tests/varmod-match.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varmod-match.mk	Sun Aug 16 20:03:53 2020
@@ -1,9 +1,22 @@
-# $NetBSD: varmod-match.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varmod-match.mk,v 1.3 2020/08/16 20:03:53 rillig Exp $
 #
 # Tests for the :M variable modifier, which filters words that match the
 # given pattern.
 
-# TODO: Implementation
+all: match-char-class
+all: slow
 
-all:
-	@:;
+
+NUMBERS=	One Two Three Four five six seven
+
+match-char-class:
+	@echo '$@:'
+	@echo '  uppercase numbers: ${NUMBERS:M[A-Z]*}'
+	@echo '  all the others: ${NUMBERS:M[^A-Z]*}'
+	@echo '  starts with non-s, ends with [ex]: ${NUMBERS:M[^s]*[ex]}'
+
+
+# Before 2020-06-13, this expression took quite a long time in Str_Match,
+# calling itself 601080390 times for 16 asterisks.
+slow:
+	@: ${:U****************:M****************b}

Added files:

Index: src/usr.bin/make/unit-tests/varmod-match-escape.exp
diff -u /dev/null src/usr.bin/make/unit-tests/varmod-match-escape.exp:1.1
--- /dev/null	Sun Aug 16 20:03:53 2020
+++ src/usr.bin/make/unit-tests/varmod-match-escape.exp	Sun Aug 16 20:03:53 2020
@@ -0,0 +1,3 @@
+Pattern[SPECIALS] for [\: : \\ * \*] is [\:]
+Pattern[SPECIALS] for [\: : \\ * \*] is [:]
+exit status 0
Index: src/usr.bin/make/unit-tests/varmod-match-escape.mk
diff -u /dev/null src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.1
--- /dev/null	Sun Aug 16 20:03:53 2020
+++ src/usr.bin/make/unit-tests/varmod-match-escape.mk	Sun Aug 16 20:03:53 2020
@@ -0,0 +1,20 @@
+# $NetBSD: varmod-match-escape.mk,v 1.1 2020/08/16 20:03:53 rillig Exp $
+#
+# As of 2020-08-01, the :M and :N modifiers interpret backslashes differently,
+# depending on whether there was a variable expression somewhere before the
+# first backslash or not.  See ApplyModifier_Match, "copy = TRUE".
+#
+# Apart from the different and possibly confusing debug output, there is no
+# difference in behavior.  When parsing the modifier text, only \{, \} and \:
+# are unescaped, and in the pattern matching these have the same meaning as
+# their plain variants '{', '}' and ':'.  In the pattern matching from
+# Str_Match, only \*, \? or \[ would make a noticeable difference.
+SPECIALS=	\: : \\ * \*
+RELEVANT=	yes
+.if ${SPECIALS:M${:U}\:} != ${SPECIALS:M\:${:U}}
+.warning unexpected
+.endif
+RELEVANT=	no
+
+all:
+	@:;

Reply via email to