Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make/unit-tests make(1): move tests for the :M modif...
details: https://anonhg.NetBSD.org/src/rev/69382c451e53
branches: trunk
changeset: 942708:69382c451e53
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Aug 16 20:03:52 2020 +0000
description:
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.
diffstat:
distrib/sets/lists/tests/mi | 4 ++-
usr.bin/make/unit-tests/Makefile | 6 ++++-
usr.bin/make/unit-tests/modmatch.exp | 3 --
usr.bin/make/unit-tests/modmatch.mk | 31 +-----------------------
usr.bin/make/unit-tests/varmod-match-escape.exp | 3 ++
usr.bin/make/unit-tests/varmod-match-escape.mk | 20 ++++++++++++++++
usr.bin/make/unit-tests/varmod-match.exp | 4 +++
usr.bin/make/unit-tests/varmod-match.mk | 21 +++++++++++++---
8 files changed, 54 insertions(+), 38 deletions(-)
diffs (183 lines):
diff -r 330723d0dfe1 -r 69382c451e53 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Aug 16 18:40:13 2020 +0000
+++ b/distrib/sets/lists/tests/mi Sun Aug 16 20:03:52 2020 +0000
@@ -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
diff -r 330723d0dfe1 -r 69382c451e53 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Sun Aug 16 18:40:13 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile Sun Aug 16 20:03:52 2020 +0000
@@ -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-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.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 @@
# 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
diff -r 330723d0dfe1 -r 69382c451e53 usr.bin/make/unit-tests/modmatch.exp
--- a/usr.bin/make/unit-tests/modmatch.exp Sun Aug 16 18:40:13 2020 +0000
+++ b/usr.bin/make/unit-tests/modmatch.exp Sun Aug 16 20:03:52 2020 +0000
@@ -14,7 +14,4 @@
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
diff -r 330723d0dfe1 -r 69382c451e53 usr.bin/make/unit-tests/modmatch.mk
--- a/usr.bin/make/unit-tests/modmatch.mk Sun Aug 16 18:40:13 2020 +0000
+++ b/usr.bin/make/unit-tests/modmatch.mk Sun Aug 16 20:03:52 2020 +0000
@@ -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 = 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 @@
@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
diff -r 330723d0dfe1 -r 69382c451e53 usr.bin/make/unit-tests/varmod-match-escape.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/varmod-match-escape.exp Sun Aug 16 20:03:52 2020 +0000
@@ -0,0 +1,3 @@
+Pattern[SPECIALS] for [\: : \\ * \*] is [\:]
+Pattern[SPECIALS] for [\: : \\ * \*] is [:]
+exit status 0
diff -r 330723d0dfe1 -r 69382c451e53 usr.bin/make/unit-tests/varmod-match-escape.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/varmod-match-escape.mk Sun Aug 16 20:03:52 2020 +0000
@@ -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:
+ @:;
diff -r 330723d0dfe1 -r 69382c451e53 usr.bin/make/unit-tests/varmod-match.exp
--- a/usr.bin/make/unit-tests/varmod-match.exp Sun Aug 16 18:40:13 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-match.exp Sun Aug 16 20:03:52 2020 +0000
@@ -1,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
diff -r 330723d0dfe1 -r 69382c451e53 usr.bin/make/unit-tests/varmod-match.mk
--- a/usr.bin/make/unit-tests/varmod-match.mk Sun Aug 16 18:40:13 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-match.mk Sun Aug 16 20:03:52 2020 +0000
@@ -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
+
+
+NUMBERS= One Two Three Four five six seven
-all:
- @:;
+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}
Home |
Main Index |
Thread Index |
Old Index