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 tests/make: clean up tests for the '...



details:   https://anonhg.NetBSD.org/src/rev/95e6c1fd2c99
branches:  trunk
changeset: 376399:95e6c1fd2c99
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jun 16 07:20:45 2023 +0000

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

diffstat:

 distrib/sets/lists/tests/mi             |    6 +-
 usr.bin/make/unit-tests/Makefile        |    3 +-
 usr.bin/make/unit-tests/modmatch.exp    |   17 ----
 usr.bin/make/unit-tests/modmatch.mk     |   30 --------
 usr.bin/make/unit-tests/modmisc.exp     |    1 -
 usr.bin/make/unit-tests/modmisc.mk      |   10 +--
 usr.bin/make/unit-tests/varmod-subst.mk |  110 ++++++++++++++++++++-----------
 7 files changed, 79 insertions(+), 98 deletions(-)

diffs (300 lines):

diff -r 3fbf1c7b5a61 -r 95e6c1fd2c99 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Fri Jun 16 07:12:46 2023 +0000
+++ b/distrib/sets/lists/tests/mi       Fri Jun 16 07:20:45 2023 +0000
@@ -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 -r 3fbf1c7b5a61 -r 95e6c1fd2c99 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Fri Jun 16 07:12:46 2023 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Fri Jun 16 07:20:45 2023 +0000
@@ -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 -r 3fbf1c7b5a61 -r 95e6c1fd2c99 usr.bin/make/unit-tests/modmatch.exp
--- a/usr.bin/make/unit-tests/modmatch.exp      Fri Jun 16 07:12:46 2023 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r 3fbf1c7b5a61 -r 95e6c1fd2c99 usr.bin/make/unit-tests/modmatch.mk
--- a/usr.bin/make/unit-tests/modmatch.mk       Fri Jun 16 07:12:46 2023 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r 3fbf1c7b5a61 -r 95e6c1fd2c99 usr.bin/make/unit-tests/modmisc.exp
--- a/usr.bin/make/unit-tests/modmisc.exp       Fri Jun 16 07:12:46 2023 +0000
+++ b/usr.bin/make/unit-tests/modmisc.exp       Fri Jun 16 07:20:45 2023 +0000
@@ -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 -r 3fbf1c7b5a61 -r 95e6c1fd2c99 usr.bin/make/unit-tests/modmisc.mk
--- a/usr.bin/make/unit-tests/modmisc.mk        Fri Jun 16 07:12:46 2023 +0000
+++ b/usr.bin/make/unit-tests/modmisc.mk        Fri Jun 16 07:20:45 2023 +0000
@@ -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 -r 3fbf1c7b5a61 -r 95e6c1fd2c99 usr.bin/make/unit-tests/varmod-subst.mk
--- a/usr.bin/make/unit-tests/varmod-subst.mk   Fri Jun 16 07:12:46 2023 +0000
+++ b/usr.bin/make/unit-tests/varmod-subst.mk   Fri Jun 16 07:20:45 2023 +0000
@@ -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"
+.  error
 .endif
 
-.if ${WORDS:S,e,*,g} != "s*qu*nc*s of l*tt*rs"
-.  warning The :S modifier flag 'g' does not replace every occurrence.
+# 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"
+.  error
 .endif
 
-.if ${WORDS:S,^sequ,occurr,} != "occurrences of letters"
-.  warning The :S modifier fails for a short match anchored at the start.
+# 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"
+.  error
 .endif
 
-.if ${WORDS:S,^of,with,} != "sequences with letters"
-.  warning The :S modifier fails for an exact match anchored at the start.
+# The :S modifier does not match if the pattern is longer than the word.
+.if ${WORDS:S,^office,does not match,} != ${WORDS}
+.  warning
 .endif
 
-.if ${WORDS:S,^office,does not match,} != ${WORDS}
-.  warning The :S modifier matches a too long pattern anchored at the start.
+# 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"
+.  error
 .endif
 
-.if ${WORDS:S,f$,r,} != "sequences or letters"
-.  warning The :S modifier fails for a short match anchored at the end.
+# The :S modifier with a '$' anchor replaces at most one occurrence per word.
+.if ${WORDS:S,s$,,} != "sequence of letter"
+.  error
 .endif
 
-.if ${WORDS:S,s$,,} != "sequence of letter"
-.  warning The :S modifier fails to replace one occurrence per word.
+# The :S modifier with a '$' anchor replaces the whole word if that word is
+# exactly the pattern.
+.if ${WORDS:S,of$,,} != "sequences letters"
+.  error
 .endif
 
-.if ${WORDS:S,of$,,} != "sequences letters"
-.  warning The :S modifier fails for an exact match anchored at the end.
+# 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
 .endif
 
-.if ${WORDS:S,eof$,,} != ${WORDS}
-.  warning The :S modifier matches a too long pattern anchored at the end.
+# The :S modifier with the '^' and '$' anchors matches an exact word.
+.if ${WORDS:S,^of$,,} != "sequences letters"
+.  error
 .endif
 
-.if ${WORDS:S,^of$,,} != "sequences letters"
-.  warning The :S modifier does not match a word anchored at both ends.
+# 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}
+.  error
 .endif
 
-.if ${WORDS:S,^o$,,} != ${WORDS}
-.  warning The :S modifier matches a prefix anchored at both ends.
+# 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}
+.  error
 .endif
 
-.if ${WORDS:S,^f$,,} != ${WORDS}
-.  warning The :S modifier matches a suffix anchored at both ends.
+# 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}
+.  error
 .endif
 
-.if ${WORDS:S,^eof$,,} != ${WORDS}
-.  warning The :S modifier matches a too long prefix anchored at both ends.
+# 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}
+.  error
 .endif
 
-.if ${WORDS:S,^office$,,} != ${WORDS}
-.  warning The :S modifier matches a too long suffix anchored at both ends.
+# 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
 .endif
 
-.if ${WORDS:S,*,replacement,} != ${WORDS}
-.  error The '*' seems to be interpreted as a wildcard of some kind.
+# 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
 .endif
 
-.if ${WORDS:S,.,replacement,} != ${WORDS}
-.  error The '.' seems to be interpreted as a wildcard of some kind.
-.endif
-
+# The '&' in the replacement is a placeholder for the text matched by the
+# pattern.
 .if ${:Uvalue:S,^val,&,} != "value"
 .  error
 .endif



Home | Main Index | Thread Index | Old Index