Module Name:    src
Committed By:   rillig
Date:           Fri Jun 16 07:20:45 UTC 2023

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/usr.bin/make/unit-tests: Makefile modmisc.exp modmisc.mk
            varmod-subst.mk
Removed Files:
        src/usr.bin/make/unit-tests: modmatch.exp modmatch.mk

Log Message:
tests/make: clean up tests for the ':M' and ':S' modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.1267 -r1.1268 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.336 -r1.337 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.4 -r0 src/usr.bin/make/unit-tests/modmatch.exp
cvs rdiff -u -r1.9 -r0 src/usr.bin/make/unit-tests/modmatch.mk
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/make/unit-tests/modmisc.exp
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/make/unit-tests/modmisc.mk
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-subst.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.1267 src/distrib/sets/lists/tests/mi:1.1268
--- src/distrib/sets/lists/tests/mi:1.1267	Wed Jun 14 07:20:54 2023
+++ src/distrib/sets/lists/tests/mi	Fri Jun 16 07:20:45 2023
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1267 2023/06/14 07:20:54 rillig Exp $
+# $NetBSD: mi,v 1.1268 2023/06/16 07:20:45 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5864,8 +5864,8 @@
 ./usr/tests/usr.bin/make/unit-tests/misc.mk					tests-obsolete		obsolete
 ./usr/tests/usr.bin/make/unit-tests/moderrs.exp					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/moderrs.mk					tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/modmatch.exp				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/modmatch.mk					tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/modmatch.exp				tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/make/unit-tests/modmatch.mk					tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/make/unit-tests/modmisc.exp					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/modmisc.mk					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/modorder.exp				tests-obsolete		obsolete

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.336 src/usr.bin/make/unit-tests/Makefile:1.337
--- src/usr.bin/make/unit-tests/Makefile:1.336	Thu Jun  1 07:27:30 2023
+++ src/usr.bin/make/unit-tests/Makefile	Fri Jun 16 07:20:45 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.336 2023/06/01 07:27:30 rillig Exp $
+# $NetBSD: Makefile,v 1.337 2023/06/16 07:20:45 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -228,7 +228,6 @@ TESTS+=		lint
 TESTS+=		make-exported
 TESTS+=		meta-cmd-cmp
 TESTS+=		moderrs
-TESTS+=		modmatch
 TESTS+=		modmisc
 .if ${.MAKE.UID} > 0
 TESTS+=		objdir-writable

Index: src/usr.bin/make/unit-tests/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.47 src/usr.bin/make/unit-tests/modmisc.exp:1.48
--- src/usr.bin/make/unit-tests/modmisc.exp:1.47	Sun Dec 20 19:29:06 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp	Fri Jun 16 07:20:45 2023
@@ -6,7 +6,6 @@ path='/bin':'/tmp':'/':'/no/such/dir'
 path_/usr/xbin=/opt/xbin/
 paths=/bin /tmp / /no/such/dir /opt/xbin
 PATHS=/BIN /TMP / /NO/SUCH/DIR /OPT/XBIN
-The answer is 42
 S:
 C:
 @:

Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.52 src/usr.bin/make/unit-tests/modmisc.mk:1.53
--- src/usr.bin/make/unit-tests/modmisc.mk:1.52	Sun Dec 20 19:29:06 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk	Fri Jun 16 07:20:45 2023
@@ -1,4 +1,4 @@
-# $NetBSD: modmisc.mk,v 1.52 2020/12/20 19:29:06 rillig Exp $
+# $NetBSD: modmisc.mk,v 1.53 2023/06/16 07:20:45 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -15,14 +15,10 @@ MOD_HOMES=	S,/home/,/homes/,
 MOD_OPT=	@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@
 MOD_SEP=	S,:, ,g
 
-all:	modvar modvarloop modsysv emptyvar undefvar
+all:	modvar modvarloop emptyvar undefvar
 all:	mod-quote
 all:	mod-break-many-words
 
-# See also sysv.mk.
-modsysv:
-	@echo "The answer is ${libfoo.a:L:libfoo.a=42}"
-
 # Demonstrates modifiers that are given indirectly from a variable.
 modvar:
 	@echo "path='${path}'"
@@ -60,6 +56,6 @@ undefvar:
 mod-quote:
 	@echo $@: new${.newline:Q}${.newline:Q}line
 
-# Cover the bmake_realloc in Str_Words.
+# Cover the bmake_realloc in Substring_Words.
 mod-break-many-words:
 	@echo $@: ${UNDEF:U:range=500:[#]}

Index: src/usr.bin/make/unit-tests/varmod-subst.mk
diff -u src/usr.bin/make/unit-tests/varmod-subst.mk:1.11 src/usr.bin/make/unit-tests/varmod-subst.mk:1.12
--- src/usr.bin/make/unit-tests/varmod-subst.mk:1.11	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/varmod-subst.mk	Fri Jun 16 07:20:45 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-subst.mk,v 1.11 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: varmod-subst.mk,v 1.12 2023/06/16 07:20:45 rillig Exp $
 #
 # Tests for the :S,from,to, variable modifier.
 
@@ -9,83 +9,117 @@ all: mod-subst-dollar
 
 WORDS=		sequences of letters
 
+# The empty pattern never matches anything.
 .if ${WORDS:S,,,} != ${WORDS}
-.  warning The empty pattern matches something.
+.  error
 .endif
 
+# The :S modifier flag '1' is applied exactly once.
 .if ${WORDS:S,e,*,1} != "s*quences of letters"
-.  warning The :S modifier flag '1' is not applied exactly once.
+.  error
 .endif
 
+# The :S modifier flag '1' is applied to the first occurrence, no matter if
+# the occurrence is in the first word or not.
 .if ${WORDS:S,f,*,1} != "sequences o* letters"
-.  warning The :S modifier flag '1' is only applied to the first word,\
-	 not to the first occurrence.
+.  error
 .endif
 
+# The :S modifier replaces every first match per word.
 .if ${WORDS:S,e,*,} != "s*quences of l*tters"
-.  warning The :S modifier does not replace every first match per word.
+.  error
 .endif
 
+# The :S modifier flag 'g' replaces every occurrence.
 .if ${WORDS:S,e,*,g} != "s*qu*nc*s of l*tt*rs"
-.  warning The :S modifier flag 'g' does not replace every occurrence.
+.  error
 .endif
 
+# The '^' in the search pattern anchors the pattern at the beginning of each
+# word, thereby matching a prefix.
 .if ${WORDS:S,^sequ,occurr,} != "occurrences of letters"
-.  warning The :S modifier fails for a short match anchored at the start.
+.  error
 .endif
 
+# The :S modifier with a '^' anchor replaces the whole word if that word is
+# exactly the pattern.
 .if ${WORDS:S,^of,with,} != "sequences with letters"
-.  warning The :S modifier fails for an exact match anchored at the start.
+.  error
 .endif
 
+# The :S modifier does not match if the pattern is longer than the word.
 .if ${WORDS:S,^office,does not match,} != ${WORDS}
-.  warning The :S modifier matches a too long pattern anchored at the start.
+.  warning
 .endif
 
+# The '$' in the search pattern anchors the pattern at the end of each word,
+# thereby matching a suffix.
 .if ${WORDS:S,f$,r,} != "sequences or letters"
-.  warning The :S modifier fails for a short match anchored at the end.
+.  error
 .endif
 
+# The :S modifier with a '$' anchor replaces at most one occurrence per word.
 .if ${WORDS:S,s$,,} != "sequence of letter"
-.  warning The :S modifier fails to replace one occurrence per word.
+.  error
 .endif
 
+# The :S modifier with a '$' anchor replaces the whole word if that word is
+# exactly the pattern.
 .if ${WORDS:S,of$,,} != "sequences letters"
-.  warning The :S modifier fails for an exact match anchored at the end.
+.  error
 .endif
 
+# The :S modifier with a '$' anchor and a pattern that is longer than a word
+# cannot match that word.
 .if ${WORDS:S,eof$,,} != ${WORDS}
-.  warning The :S modifier matches a too long pattern anchored at the end.
+.  warning
 .endif
 
+# The :S modifier with the '^' and '$' anchors matches an exact word.
 .if ${WORDS:S,^of$,,} != "sequences letters"
-.  warning The :S modifier does not match a word anchored at both ends.
+.  error
 .endif
 
+# The :S modifier with the '^' and '$' anchors does not match a word that
+# starts with the pattern but is longer than the pattern.
 .if ${WORDS:S,^o$,,} != ${WORDS}
-.  warning The :S modifier matches a prefix anchored at both ends.
+.  error
 .endif
 
+# The :S modifier with the '^' and '$' anchors does not match a word that ends
+# with the pattern but is longer than the pattern.
 .if ${WORDS:S,^f$,,} != ${WORDS}
-.  warning The :S modifier matches a suffix anchored at both ends.
+.  error
 .endif
 
+# The :S modifier with the '^' and '$' anchors does not match a word if the
+# pattern ends with the word but is longer than the word.
 .if ${WORDS:S,^eof$,,} != ${WORDS}
-.  warning The :S modifier matches a too long prefix anchored at both ends.
+.  error
 .endif
 
+# The :S modifier with the '^' and '$' anchors does not match a word if the
+# pattern starts with the word but is longer than the word.
 .if ${WORDS:S,^office$,,} != ${WORDS}
-.  warning The :S modifier matches a too long suffix anchored at both ends.
+.  error
 .endif
 
+# Except for the '^' and '$' anchors, the pattern does not contain any special
+# characters, so the '*' from the pattern would only match a literal '*' in a
+# word.
 .if ${WORDS:S,*,replacement,} != ${WORDS}
-.  error The '*' seems to be interpreted as a wildcard of some kind.
+.  error
 .endif
 
+# Except for the '^' and '$' anchors, the pattern does not contain any special
+# characters, so the '.' from the pattern would only match a literal '.' in a
+# word.
 .if ${WORDS:S,.,replacement,} != ${WORDS}
-.  error The '.' seems to be interpreted as a wildcard of some kind.
+.  error
 .endif
 
+# The '&' in the replacement is a placeholder for the text matched by the
+# pattern.
 .if ${:Uvalue:S,^val,&,} != "value"
 .  error
 .endif

Reply via email to