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): merge the SysV modifier tes...



details:   https://anonhg.NetBSD.org/src/rev/1392b6c30d08
branches:  trunk
changeset: 941822:1392b6c30d08
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 31 11:06:24 2020 +0000

description:
make(1): merge the SysV modifier tests into varmod-sysv

diffstat:

 distrib/sets/lists/tests/mi            |   6 +-
 usr.bin/make/unit-tests/Makefile       |   3 +-
 usr.bin/make/unit-tests/sysv.exp       |  15 ---------
 usr.bin/make/unit-tests/sysv.mk        |  43 --------------------------
 usr.bin/make/unit-tests/varmod-sysv.mk |  55 +++++++++++++++++++++++++++++++++-
 5 files changed, 58 insertions(+), 64 deletions(-)

diffs (193 lines):

diff -r 0465d903a8e8 -r 1392b6c30d08 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Oct 31 11:03:18 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Sat Oct 31 11:06:24 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.952 2020/10/31 11:03:18 rillig Exp $
+# $NetBSD: mi,v 1.953 2020/10/31 11:06:24 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5264,8 +5264,8 @@
 ./usr/tests/usr.bin/make/unit-tests/suffixes.mk                                        tests-obsolete          obsolete
 ./usr/tests/usr.bin/make/unit-tests/sunshcmd.exp                               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/sunshcmd.mk                                        tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/sysv.exp                                   tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/sysv.mk                                    tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/sysv.exp                                   tests-obsolete          obsolete
+./usr/tests/usr.bin/make/unit-tests/sysv.mk                                    tests-obsolete          obsolete
 ./usr/tests/usr.bin/make/unit-tests/ternary.exp                                        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/ternary.mk                                 tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/unexport-env.exp                           tests-usr.bin-tests     compattestfile,atf
diff -r 0465d903a8e8 -r 1392b6c30d08 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sat Oct 31 11:03:18 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sat Oct 31 11:06:24 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.177 2020/10/30 15:03:58 rillig Exp $
+# $NetBSD: Makefile,v 1.178 2020/10/31 11:06:24 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -261,7 +261,6 @@
 TESTS+=                suff-transform-expand
 TESTS+=                suff-transform-select
 TESTS+=                sunshcmd
-TESTS+=                sysv
 TESTS+=                ternary
 TESTS+=                unexport
 TESTS+=                unexport-env
diff -r 0465d903a8e8 -r 1392b6c30d08 usr.bin/make/unit-tests/sysv.exp
--- a/usr.bin/make/unit-tests/sysv.exp  Sat Oct 31 11:03:18 2020 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-FOOBAR =
-FOOBAR = foobar fubar
-fun
-fun
-fun
-In the Sun
-acme
-aam.d
-sam.c
-a%.c
-asam.c.c
-asam.c
-a.c.c
-
-exit status 0
diff -r 0465d903a8e8 -r 1392b6c30d08 usr.bin/make/unit-tests/sysv.mk
--- a/usr.bin/make/unit-tests/sysv.mk   Sat Oct 31 11:03:18 2020 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-# $NetBSD: sysv.mk,v 1.15 2020/10/24 08:50:17 rillig Exp $
-
-all: foo fun sam bla
-
-FOO?=
-FOOBAR=        ${FOO:=bar}
-
-_this:=        ${.PARSEDIR}/${.PARSEFILE}
-
-B=     /b
-S=     /
-FUN=   ${B}${S}fun
-SUN=   the Sun
-
-# we expect nothing when FOO is empty
-foo:
-       @echo FOOBAR = ${FOOBAR}
-.if empty(FOO)
-       @FOO="foo fu" ${.MAKE} -f ${_this} foo
-.endif
-
-fun:
-       @echo ${FUN:T}
-       @echo ${FUN:${B}${S}fun=fun}
-       @echo ${FUN:${B}${S}%=%}
-       @echo ${In:L:%=% ${SUN}}
-
-
-SAM=   sam.c
-
-sam:
-       @echo ${SAM:s%.c=acme}
-       @echo ${SAM:s%.c=a%.d}
-       @echo ${SAM:s.c=a%.d}
-       @echo ${SAM:sam.c=a%.c}
-       @echo ${SAM:%=a%.c}
-       @echo ${SAM:%.c=a%.c}
-       @echo ${SAM:sam%=a%.c}
-
-BLA=
-
-bla:
-       @echo $(BLA:%=foo/%x)
diff -r 0465d903a8e8 -r 1392b6c30d08 usr.bin/make/unit-tests/varmod-sysv.mk
--- a/usr.bin/make/unit-tests/varmod-sysv.mk    Sat Oct 31 11:03:18 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-sysv.mk    Sat Oct 31 11:06:24 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-sysv.mk,v 1.8 2020/10/31 10:18:32 rillig Exp $
+# $NetBSD: varmod-sysv.mk,v 1.9 2020/10/31 11:06:24 rillig Exp $
 #
 # Tests for the ${VAR:from=to} variable modifier, which replaces the suffix
 # "from" with "to".  It can also use '%' as a wildcard.
@@ -35,6 +35,13 @@
 .  error
 .endif
 
+# The :from=to modifier can also be used to surround each word by strings.
+# It might be tempting to use this for enclosing a string in quotes for the
+# shell, but that's the job of the :Q modifier.
+.if ${one two three:L:%=(%)} != "(one) (two) (three)"
+.  error
+.endif
+
 # When the :from=to modifier is parsed, it lasts until the closing brace
 # or parenthesis.  The :Q in the below expression may look like a modifier
 # but isn't.  It is part of the replacement string.
@@ -42,6 +49,38 @@
 .  error
 .endif
 
+# In the :from=to modifier, both parts can contain variable expressions.
+.if ${one two:L:${:Uone}=${:U1}} != "1 two"
+.  error
+.endif
+
+# In the :from=to modifier, the "from" part is expanded exactly once.
+.if ${:U\$ \$\$ \$\$\$\$:${:U\$\$\$\$}=4} != "\$ \$\$ 4"
+.  error
+.endif
+
+# In the :from=to modifier, the "to" part is expanded exactly twice.
+# XXX: The right-hand side should be expanded only once.
+# XXX: It's hard to get the escaping correct here, and to read that.
+# XXX: It's not intuitive why the closing brace must be escaped but not
+#      the opening brace.
+.if ${:U1 2 4:4=${:Uonce\${\:Utwice\}}} != "1 2 oncetwice"
+.  error
+.endif
+
+# The replacement string can contain spaces, thereby changing the number
+# of words in the variable expression.
+.if ${In:L:%=% ${:Uthe Sun}} != "In the Sun"
+.  error
+.endif
+
+# If the variable is empty, it is debatable whether it consists of a single
+# empty word, or no word at all.  The :from=to modifier treats it as no
+# word at all.
+.if ${:L:=suffix} != ""
+.  error
+.endif
+
 # Before 2020-07-19, an ampersand could be used in the replacement part
 # of a SysV substitution modifier, and it was replaced with the whole match,
 # just like in the :S modifier.
@@ -87,6 +126,12 @@
 .  error
 .endif
 
+# It's also possible to modify each word by replacing the prefix and adding
+# a suffix.
+.if ${one two:L:o%=a%w} != "anew two"
+.  error
+.endif
+
 # Each word gets the suffix "X" appended.
 .if ${one two:L:=X} != "oneX twoX"
 .  error
@@ -143,6 +188,14 @@
 .  error
 .endif
 
+# The :from=to modifier can be used to replace both the prefix and a suffix
+# of a word with other strings.  This is not possible with a single :S
+# modifier, and using a :C modifier for the same task looks more complicated
+# in many cases.
+.if ${prefix-middle-suffix:L:prefix-%-suffix=p-%-s} != "p-middle-s"
+.  error
+.endif
+
 # As of 2020-10-06, the right-hand side of the SysV modifier is expanded
 # twice.  The first expansion happens in ApplyModifier_SysV, where the
 # modifier is split into its two parts.  The second expansion happens



Home | Main Index | Thread Index | Old Index