diff options
| author | rillig <rillig@NetBSD.org> | 2023-06-16 07:20:45 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2023-06-16 07:20:45 +0000 |
| commit | eb7680386fcf85aa042aedb210d4d4539b167779 (patch) | |
| tree | e1c447d571a52150ae45c48bc711b43180203b3b | |
| parent | 1e6e5f6ee8c5e2de1fcdcf30abb64336ac692a65 (diff) | |
tests/make: clean up tests for the ':M' and ':S' modifiers
| -rw-r--r-- | distrib/sets/lists/tests/mi | 6 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/Makefile | 3 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/modmatch.exp | 17 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/modmatch.mk | 30 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/modmisc.exp | 1 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/modmisc.mk | 10 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/varmod-subst.mk | 76 |
7 files changed, 62 insertions, 81 deletions
diff --git a/distrib/sets/lists/tests/mi b/distrib/sets/lists/tests/mi index 68b55a7607b..b45e3ec2cde 100644 --- a/distrib/sets/lists/tests/mi +++ b/distrib/sets/lists/tests/mi @@ -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 diff --git a/usr.bin/make/unit-tests/Makefile b/usr.bin/make/unit-tests/Makefile index baf82523cac..be28b45093a 100644 --- a/usr.bin/make/unit-tests/Makefile +++ b/usr.bin/make/unit-tests/Makefile @@ -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 diff --git a/usr.bin/make/unit-tests/modmatch.exp b/usr.bin/make/unit-tests/modmatch.exp deleted file mode 100644 index fcaf6c02ed6..00000000000 --- a/usr.bin/make/unit-tests/modmatch.exp +++ /dev/null @@ -1,17 +0,0 @@ -LIB=a X_LIBS:M${LIB${LIB:tu}} is "/tmp/liba.a" -LIB=a X_LIBS:M*/lib${LIB}.a is "/tmp/liba.a" -LIB=a X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBA.A" -LIB=b X_LIBS:M${LIB${LIB:tu}} is "" -LIB=b X_LIBS:M*/lib${LIB}.a is "" -LIB=b X_LIBS:M*/lib${LIB}.a:tu is "" -LIB=c X_LIBS:M${LIB${LIB:tu}} is "" -LIB=c X_LIBS:M*/lib${LIB}.a is "" -LIB=c X_LIBS:M*/lib${LIB}.a:tu is "" -LIB=d X_LIBS:M${LIB${LIB:tu}} is "/tmp/libd.a" -LIB=d X_LIBS:M*/lib${LIB}.a is "/tmp/libd.a" -LIB=d X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBD.A" -LIB=e X_LIBS:M${LIB${LIB:tu}} is "/tmp/libe.a" -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 -exit status 0 diff --git a/usr.bin/make/unit-tests/modmatch.mk b/usr.bin/make/unit-tests/modmatch.mk deleted file mode 100644 index 7dcacf09da6..00000000000 --- a/usr.bin/make/unit-tests/modmatch.mk +++ /dev/null @@ -1,30 +0,0 @@ -# $NetBSD: modmatch.mk,v 1.9 2020/10/24 08:50:17 rillig Exp $ -# -# Tests for the :M and :S modifiers. - -X= a b c d e - -.for x in $X -LIB${x:tu}= /tmp/lib$x.a -.endfor - -X_LIBS= ${LIBA} ${LIBD} ${LIBE} - -LIB?= a - -var= head -res= no -.if !empty(var:M${:Uhead\:tail:C/:.*//}) -res= OK -.endif - -all: show-libs - -show-libs: - @for x in $X; do ${.MAKE} -f ${MAKEFILE} show LIB=$$x; done - @echo "Mscanner=${res}" - -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}"' diff --git a/usr.bin/make/unit-tests/modmisc.exp b/usr.bin/make/unit-tests/modmisc.exp index 10475e65ee0..f243511ab49 100644 --- a/usr.bin/make/unit-tests/modmisc.exp +++ b/usr.bin/make/unit-tests/modmisc.exp @@ -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: @: diff --git a/usr.bin/make/unit-tests/modmisc.mk b/usr.bin/make/unit-tests/modmisc.mk index 9ace35c1516..4868abef92f 100644 --- a/usr.bin/make/unit-tests/modmisc.mk +++ b/usr.bin/make/unit-tests/modmisc.mk @@ -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:[#]} diff --git a/usr.bin/make/unit-tests/varmod-subst.mk b/usr.bin/make/unit-tests/varmod-subst.mk index 00cae5b9399..0ddf2cfb201 100644 --- a/usr.bin/make/unit-tests/varmod-subst.mk +++ b/usr.bin/make/unit-tests/varmod-subst.mk @@ -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 |
