Sat Oct 31 11:06:24 2020 UTC ()
make(1): merge the SysV modifier tests into varmod-sysv


(rillig)
diff -r1.952 -r1.953 src/distrib/sets/lists/tests/mi
diff -r1.177 -r1.178 src/usr.bin/make/unit-tests/Makefile
diff -r1.10 -r0 src/usr.bin/make/unit-tests/sysv.exp
diff -r1.15 -r0 src/usr.bin/make/unit-tests/sysv.mk
diff -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-sysv.mk

cvs diff -r1.952 -r1.953 src/distrib/sets/lists/tests/mi (expand / switch to unified diff)

--- src/distrib/sets/lists/tests/mi 2020/10/31 11:03:18 1.952
+++ src/distrib/sets/lists/tests/mi 2020/10/31 11:06:24 1.953
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.952 2020/10/31 11:03:18 rillig Exp $ 1# $NetBSD: mi,v 1.953 2020/10/31 11:06:24 rillig Exp $
2# 2#
3# Note: don't delete entries from here - mark them as "obsolete" instead. 3# Note: don't delete entries from here - mark them as "obsolete" instead.
4# 4#
5./etc/mtree/set.tests tests-sys-root 5./etc/mtree/set.tests tests-sys-root
6./usr/libdata/debug/usr/tests tests-base-debug compattestdir 6./usr/libdata/debug/usr/tests tests-base-debug compattestdir
7./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf 7./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf
8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf 8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf
9./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf 9./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf
10./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf 10./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf
11./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf 11./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf
12./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete 12./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete
13./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete 13./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete
14./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete 14./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete
@@ -5254,28 +5254,28 @@ @@ -5254,28 +5254,28 @@
5254./usr/tests/usr.bin/make/unit-tests/suff-main.mk tests-usr.bin-tests compattestfile,atf 5254./usr/tests/usr.bin/make/unit-tests/suff-main.mk tests-usr.bin-tests compattestfile,atf
5255./usr/tests/usr.bin/make/unit-tests/suff-rebuild.exp tests-usr.bin-tests compattestfile,atf 5255./usr/tests/usr.bin/make/unit-tests/suff-rebuild.exp tests-usr.bin-tests compattestfile,atf
5256./usr/tests/usr.bin/make/unit-tests/suff-rebuild.mk tests-usr.bin-tests compattestfile,atf 5256./usr/tests/usr.bin/make/unit-tests/suff-rebuild.mk tests-usr.bin-tests compattestfile,atf
5257./usr/tests/usr.bin/make/unit-tests/suff-transform-endless.exp tests-usr.bin-tests compattestfile,atf 5257./usr/tests/usr.bin/make/unit-tests/suff-transform-endless.exp tests-usr.bin-tests compattestfile,atf
5258./usr/tests/usr.bin/make/unit-tests/suff-transform-endless.mk tests-usr.bin-tests compattestfile,atf 5258./usr/tests/usr.bin/make/unit-tests/suff-transform-endless.mk tests-usr.bin-tests compattestfile,atf
5259./usr/tests/usr.bin/make/unit-tests/suff-transform-expand.exp tests-usr.bin-tests compattestfile,atf 5259./usr/tests/usr.bin/make/unit-tests/suff-transform-expand.exp tests-usr.bin-tests compattestfile,atf
5260./usr/tests/usr.bin/make/unit-tests/suff-transform-expand.mk tests-usr.bin-tests compattestfile,atf 5260./usr/tests/usr.bin/make/unit-tests/suff-transform-expand.mk tests-usr.bin-tests compattestfile,atf
5261./usr/tests/usr.bin/make/unit-tests/suff-transform-select.exp tests-usr.bin-tests compattestfile,atf 5261./usr/tests/usr.bin/make/unit-tests/suff-transform-select.exp tests-usr.bin-tests compattestfile,atf
5262./usr/tests/usr.bin/make/unit-tests/suff-transform-select.mk tests-usr.bin-tests compattestfile,atf 5262./usr/tests/usr.bin/make/unit-tests/suff-transform-select.mk tests-usr.bin-tests compattestfile,atf
5263./usr/tests/usr.bin/make/unit-tests/suffixes.exp tests-obsolete obsolete 5263./usr/tests/usr.bin/make/unit-tests/suffixes.exp tests-obsolete obsolete
5264./usr/tests/usr.bin/make/unit-tests/suffixes.mk tests-obsolete obsolete 5264./usr/tests/usr.bin/make/unit-tests/suffixes.mk tests-obsolete obsolete
5265./usr/tests/usr.bin/make/unit-tests/sunshcmd.exp tests-usr.bin-tests compattestfile,atf 5265./usr/tests/usr.bin/make/unit-tests/sunshcmd.exp tests-usr.bin-tests compattestfile,atf
5266./usr/tests/usr.bin/make/unit-tests/sunshcmd.mk tests-usr.bin-tests compattestfile,atf 5266./usr/tests/usr.bin/make/unit-tests/sunshcmd.mk tests-usr.bin-tests compattestfile,atf
5267./usr/tests/usr.bin/make/unit-tests/sysv.exp tests-usr.bin-tests compattestfile,atf 5267./usr/tests/usr.bin/make/unit-tests/sysv.exp tests-obsolete obsolete
5268./usr/tests/usr.bin/make/unit-tests/sysv.mk tests-usr.bin-tests compattestfile,atf 5268./usr/tests/usr.bin/make/unit-tests/sysv.mk tests-obsolete obsolete
5269./usr/tests/usr.bin/make/unit-tests/ternary.exp tests-usr.bin-tests compattestfile,atf 5269./usr/tests/usr.bin/make/unit-tests/ternary.exp tests-usr.bin-tests compattestfile,atf
5270./usr/tests/usr.bin/make/unit-tests/ternary.mk tests-usr.bin-tests compattestfile,atf 5270./usr/tests/usr.bin/make/unit-tests/ternary.mk tests-usr.bin-tests compattestfile,atf
5271./usr/tests/usr.bin/make/unit-tests/unexport-env.exp tests-usr.bin-tests compattestfile,atf 5271./usr/tests/usr.bin/make/unit-tests/unexport-env.exp tests-usr.bin-tests compattestfile,atf
5272./usr/tests/usr.bin/make/unit-tests/unexport-env.mk tests-usr.bin-tests compattestfile,atf 5272./usr/tests/usr.bin/make/unit-tests/unexport-env.mk tests-usr.bin-tests compattestfile,atf
5273./usr/tests/usr.bin/make/unit-tests/unexport.exp tests-usr.bin-tests compattestfile,atf 5273./usr/tests/usr.bin/make/unit-tests/unexport.exp tests-usr.bin-tests compattestfile,atf
5274./usr/tests/usr.bin/make/unit-tests/unexport.mk tests-usr.bin-tests compattestfile,atf 5274./usr/tests/usr.bin/make/unit-tests/unexport.mk tests-usr.bin-tests compattestfile,atf
5275./usr/tests/usr.bin/make/unit-tests/use-inference.exp tests-usr.bin-tests compattestfile,atf 5275./usr/tests/usr.bin/make/unit-tests/use-inference.exp tests-usr.bin-tests compattestfile,atf
5276./usr/tests/usr.bin/make/unit-tests/use-inference.mk tests-usr.bin-tests compattestfile,atf 5276./usr/tests/usr.bin/make/unit-tests/use-inference.mk tests-usr.bin-tests compattestfile,atf
5277./usr/tests/usr.bin/make/unit-tests/var-class-cmdline.exp tests-usr.bin-tests compattestfile,atf 5277./usr/tests/usr.bin/make/unit-tests/var-class-cmdline.exp tests-usr.bin-tests compattestfile,atf
5278./usr/tests/usr.bin/make/unit-tests/var-class-cmdline.mk tests-usr.bin-tests compattestfile,atf 5278./usr/tests/usr.bin/make/unit-tests/var-class-cmdline.mk tests-usr.bin-tests compattestfile,atf
5279./usr/tests/usr.bin/make/unit-tests/var-class-env.exp tests-usr.bin-tests compattestfile,atf 5279./usr/tests/usr.bin/make/unit-tests/var-class-env.exp tests-usr.bin-tests compattestfile,atf
5280./usr/tests/usr.bin/make/unit-tests/var-class-env.mk tests-usr.bin-tests compattestfile,atf 5280./usr/tests/usr.bin/make/unit-tests/var-class-env.mk tests-usr.bin-tests compattestfile,atf
5281./usr/tests/usr.bin/make/unit-tests/var-class-global.exp tests-usr.bin-tests compattestfile,atf 5281./usr/tests/usr.bin/make/unit-tests/var-class-global.exp tests-usr.bin-tests compattestfile,atf

cvs diff -r1.177 -r1.178 src/usr.bin/make/unit-tests/Makefile (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/Makefile 2020/10/30 15:03:58 1.177
+++ src/usr.bin/make/unit-tests/Makefile 2020/10/31 11:06:24 1.178
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.177 2020/10/30 15:03:58 rillig Exp $ 1# $NetBSD: Makefile,v 1.178 2020/10/31 11:06:24 rillig Exp $
2# 2#
3# Unit tests for make(1) 3# Unit tests for make(1)
4# 4#
5# The main targets are: 5# The main targets are:
6# 6#
7# all: 7# all:
8# run all the tests 8# run all the tests
9# test: 9# test:
10# run 'all', and compare to expected results 10# run 'all', and compare to expected results
11# accept: 11# accept:
12# move generated output to expected results 12# move generated output to expected results
13# 13#
14# Settable variables 14# Settable variables
@@ -251,27 +251,26 @@ TESTS+= shell-csh @@ -251,27 +251,26 @@ TESTS+= shell-csh
251TESTS+= shell-custom 251TESTS+= shell-custom
252TESTS+= shell-ksh 252TESTS+= shell-ksh
253TESTS+= shell-sh 253TESTS+= shell-sh
254TESTS+= suff-add-later 254TESTS+= suff-add-later
255TESTS+= suff-clear-regular 255TESTS+= suff-clear-regular
256TESTS+= suff-clear-single 256TESTS+= suff-clear-single
257TESTS+= suff-lookup 257TESTS+= suff-lookup
258TESTS+= suff-main 258TESTS+= suff-main
259TESTS+= suff-rebuild 259TESTS+= suff-rebuild
260TESTS+= suff-transform-endless 260TESTS+= suff-transform-endless
261TESTS+= suff-transform-expand 261TESTS+= suff-transform-expand
262TESTS+= suff-transform-select 262TESTS+= suff-transform-select
263TESTS+= sunshcmd 263TESTS+= sunshcmd
264TESTS+= sysv 
265TESTS+= ternary 264TESTS+= ternary
266TESTS+= unexport 265TESTS+= unexport
267TESTS+= unexport-env 266TESTS+= unexport-env
268TESTS+= use-inference 267TESTS+= use-inference
269TESTS+= var-class 268TESTS+= var-class
270TESTS+= var-class-cmdline 269TESTS+= var-class-cmdline
271TESTS+= var-class-env 270TESTS+= var-class-env
272TESTS+= var-class-global 271TESTS+= var-class-global
273TESTS+= var-class-local 272TESTS+= var-class-local
274TESTS+= var-class-local-legacy 273TESTS+= var-class-local-legacy
275TESTS+= var-op 274TESTS+= var-op
276TESTS+= var-op-append 275TESTS+= var-op-append
277TESTS+= var-op-assign 276TESTS+= var-op-assign

File Deleted: src/usr.bin/make/unit-tests/Attic/sysv.exp

File Deleted: src/usr.bin/make/unit-tests/Attic/sysv.mk

cvs diff -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-sysv.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmod-sysv.mk 2020/10/31 10:18:32 1.8
+++ src/usr.bin/make/unit-tests/varmod-sysv.mk 2020/10/31 11:06:24 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: varmod-sysv.mk,v 1.8 2020/10/31 10:18:32 rillig Exp $ 1# $NetBSD: varmod-sysv.mk,v 1.9 2020/10/31 11:06:24 rillig Exp $
2# 2#
3# Tests for the ${VAR:from=to} variable modifier, which replaces the suffix 3# Tests for the ${VAR:from=to} variable modifier, which replaces the suffix
4# "from" with "to". It can also use '%' as a wildcard. 4# "from" with "to". It can also use '%' as a wildcard.
5# 5#
6# This modifier is applied when the other modifiers don't match exactly. 6# This modifier is applied when the other modifiers don't match exactly.
7# 7#
8# See ApplyModifier_SysV. 8# See ApplyModifier_SysV.
9 9
10# A typical use case for the :from=to modifier is conversion of filename 10# A typical use case for the :from=to modifier is conversion of filename
11# extensions. 11# extensions.
12.if ${src.c:L:.c=.o} != "src.o" 12.if ${src.c:L:.c=.o} != "src.o"
13. error 13. error
14.endif 14.endif
@@ -25,33 +25,72 @@ @@ -25,33 +25,72 @@
25 25
26# The :from=to modifier is therefore often combined with the :M modifier. 26# The :from=to modifier is therefore often combined with the :M modifier.
27.if ${src.c src.h:L:M*.c:.c=.o} != "src.o" 27.if ${src.c src.h:L:M*.c:.c=.o} != "src.o"
28. error 28. error
29.endif 29.endif
30 30
31# Another use case for the :from=to modifier is to append a suffix to each 31# Another use case for the :from=to modifier is to append a suffix to each
32# word. In this case, the "from" string is empty, therefore it always 32# word. In this case, the "from" string is empty, therefore it always
33# matches. The same effect can be achieved with the :S,$,teen, modifier. 33# matches. The same effect can be achieved with the :S,$,teen, modifier.
34.if ${four six seven nine:L:=teen} != "fourteen sixteen seventeen nineteen" 34.if ${four six seven nine:L:=teen} != "fourteen sixteen seventeen nineteen"
35. error 35. error
36.endif 36.endif
37 37
 38# The :from=to modifier can also be used to surround each word by strings.
 39# It might be tempting to use this for enclosing a string in quotes for the
 40# shell, but that's the job of the :Q modifier.
 41.if ${one two three:L:%=(%)} != "(one) (two) (three)"
 42. error
 43.endif
 44
38# When the :from=to modifier is parsed, it lasts until the closing brace 45# When the :from=to modifier is parsed, it lasts until the closing brace
39# or parenthesis. The :Q in the below expression may look like a modifier 46# or parenthesis. The :Q in the below expression may look like a modifier
40# but isn't. It is part of the replacement string. 47# but isn't. It is part of the replacement string.
41.if ${a b c d e:L:%a=x:Q} != "x:Q b c d e" 48.if ${a b c d e:L:%a=x:Q} != "x:Q b c d e"
42. error 49. error
43.endif 50.endif
44 51
 52# In the :from=to modifier, both parts can contain variable expressions.
 53.if ${one two:L:${:Uone}=${:U1}} != "1 two"
 54. error
 55.endif
 56
 57# In the :from=to modifier, the "from" part is expanded exactly once.
 58.if ${:U\$ \$\$ \$\$\$\$:${:U\$\$\$\$}=4} != "\$ \$\$ 4"
 59. error
 60.endif
 61
 62# In the :from=to modifier, the "to" part is expanded exactly twice.
 63# XXX: The right-hand side should be expanded only once.
 64# XXX: It's hard to get the escaping correct here, and to read that.
 65# XXX: It's not intuitive why the closing brace must be escaped but not
 66# the opening brace.
 67.if ${:U1 2 4:4=${:Uonce\${\:Utwice\}}} != "1 2 oncetwice"
 68. error
 69.endif
 70
 71# The replacement string can contain spaces, thereby changing the number
 72# of words in the variable expression.
 73.if ${In:L:%=% ${:Uthe Sun}} != "In the Sun"
 74. error
 75.endif
 76
 77# If the variable is empty, it is debatable whether it consists of a single
 78# empty word, or no word at all. The :from=to modifier treats it as no
 79# word at all.
 80.if ${:L:=suffix} != ""
 81. error
 82.endif
 83
45# Before 2020-07-19, an ampersand could be used in the replacement part 84# Before 2020-07-19, an ampersand could be used in the replacement part
46# of a SysV substitution modifier, and it was replaced with the whole match, 85# of a SysV substitution modifier, and it was replaced with the whole match,
47# just like in the :S modifier. 86# just like in the :S modifier.
48# 87#
49# This was probably a copy-and-paste mistake since the code for the SysV 88# This was probably a copy-and-paste mistake since the code for the SysV
50# modifier looked a lot like the code for the :S and :C modifiers. 89# modifier looked a lot like the code for the :S and :C modifiers.
51# The ampersand is not mentioned in the manual page. 90# The ampersand is not mentioned in the manual page.
52.if ${a.bcd.e:L:a.%=%} != "bcd.e" 91.if ${a.bcd.e:L:a.%=%} != "bcd.e"
53. error 92. error
54.endif 93.endif
55# Before 2020-07-19, the result of the expression was "a.bcd.e". 94# Before 2020-07-19, the result of the expression was "a.bcd.e".
56.if ${a.bcd.e:L:a.%=&} != "&" 95.if ${a.bcd.e:L:a.%=&} != "&"
57. error 96. error
@@ -77,26 +116,32 @@ @@ -77,26 +116,32 @@
77.endif 116.endif
78 117
79# Words that don't match are copied unmodified. 118# Words that don't match are copied unmodified.
80.if ${:Ufile.c file.h:%.c=%.cpp} != "file.cpp file.h" 119.if ${:Ufile.c file.h:%.c=%.cpp} != "file.cpp file.h"
81. error 120. error
82.endif 121.endif
83 122
84# The % placeholder can be anywhere in the string, it doesn't have to be at 123# The % placeholder can be anywhere in the string, it doesn't have to be at
85# the beginning of the pattern. 124# the beginning of the pattern.
86.if ${:Ufile.c other.c:file.%=renamed.%} != "renamed.c other.c" 125.if ${:Ufile.c other.c:file.%=renamed.%} != "renamed.c other.c"
87. error 126. error
88.endif 127.endif
89 128
 129# It's also possible to modify each word by replacing the prefix and adding
 130# a suffix.
 131.if ${one two:L:o%=a%w} != "anew two"
 132. error
 133.endif
 134
90# Each word gets the suffix "X" appended. 135# Each word gets the suffix "X" appended.
91.if ${one two:L:=X} != "oneX twoX" 136.if ${one two:L:=X} != "oneX twoX"
92. error 137. error
93.endif 138.endif
94 139
95# The suffix "o" is replaced with "X". 140# The suffix "o" is replaced with "X".
96.if ${one two:L:o=X} != "one twX" 141.if ${one two:L:o=X} != "one twX"
97. error 142. error
98.endif 143.endif
99 144
100# The suffix "o" is replaced with nothing. 145# The suffix "o" is replaced with nothing.
101.if ${one two:L:o=} != "one tw" 146.if ${one two:L:o=} != "one tw"
102. error 147. error
@@ -133,26 +178,34 @@ @@ -133,26 +178,34 @@
133 178
134# In the replacement, only the first '%' is the placeholder, all others 179# In the replacement, only the first '%' is the placeholder, all others
135# are literal percent characters. 180# are literal percent characters.
136.if ${one two:L:%=%%} != "one% two%" 181.if ${one two:L:%=%%} != "one% two%"
137. error 182. error
138.endif 183.endif
139 184
140# In the word "one", only a prefix of the pattern suffix "nes" matches, 185# In the word "one", only a prefix of the pattern suffix "nes" matches,
141# the whole word is too short. Therefore it doesn't match. 186# the whole word is too short. Therefore it doesn't match.
142.if ${one two:L:%nes=%xxx} != "one two" 187.if ${one two:L:%nes=%xxx} != "one two"
143. error 188. error
144.endif 189.endif
145 190
 191# The :from=to modifier can be used to replace both the prefix and a suffix
 192# of a word with other strings. This is not possible with a single :S
 193# modifier, and using a :C modifier for the same task looks more complicated
 194# in many cases.
 195.if ${prefix-middle-suffix:L:prefix-%-suffix=p-%-s} != "p-middle-s"
 196. error
 197.endif
 198
146# As of 2020-10-06, the right-hand side of the SysV modifier is expanded 199# As of 2020-10-06, the right-hand side of the SysV modifier is expanded
147# twice. The first expansion happens in ApplyModifier_SysV, where the 200# twice. The first expansion happens in ApplyModifier_SysV, where the
148# modifier is split into its two parts. The second expansion happens 201# modifier is split into its two parts. The second expansion happens
149# when each word is replaced in ModifyWord_SYSVSubst. 202# when each word is replaced in ModifyWord_SYSVSubst.
150# XXX: This is unexpected. Add more test case to demonstrate the effects 203# XXX: This is unexpected. Add more test case to demonstrate the effects
151# of removing one of the expansions. 204# of removing one of the expansions.
152VALUE= value 205VALUE= value
153INDIRECT= 1:${VALUE} 2:$${VALUE} 4:$$$${VALUE} 206INDIRECT= 1:${VALUE} 2:$${VALUE} 4:$$$${VALUE}
154.if ${x:L:x=${INDIRECT}} != "1:value 2:value 4:\${VALUE}" 207.if ${x:L:x=${INDIRECT}} != "1:value 2:value 4:\${VALUE}"
155. error 208. error
156.endif 209.endif
157 210
158all: 211all: