Module Name: src
Committed By: rillig
Date: Wed May 10 13:03:06 UTC 2023
Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile directive-for.exp
directive-for.mk
Removed Files:
src/usr.bin/make/unit-tests: forloop.exp forloop.mk
Log Message:
tests/make: clean up tests for .for loops
Most of the tests from forloop.mk were already in directive-for.mk.
To generate a diff of this commit:
cvs rdiff -u -r1.1259 -r1.1260 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.334 -r1.335 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/directive-for.exp
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/directive-for.mk
cvs rdiff -u -r1.4 -r0 src/usr.bin/make/unit-tests/forloop.exp
cvs rdiff -u -r1.7 -r0 src/usr.bin/make/unit-tests/forloop.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.1259 src/distrib/sets/lists/tests/mi:1.1260
--- src/distrib/sets/lists/tests/mi:1.1259 Tue May 9 20:14:28 2023
+++ src/distrib/sets/lists/tests/mi Wed May 10 13:03:06 2023
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1259 2023/05/09 20:14:28 sjg Exp $
+# $NetBSD: mi,v 1.1260 2023/05/10 13:03:06 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -5746,8 +5746,8 @@
./usr/tests/usr.bin/make/unit-tests/export-variants.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/export.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/export.mk tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/forloop.exp tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/forloop.mk tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/forloop.exp tests-obsolete obsolete,atf
+./usr/tests/usr.bin/make/unit-tests/forloop.mk tests-obsolete obsolete,atf
./usr/tests/usr.bin/make/unit-tests/forsubst.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/forsubst.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/gnode-submake.exp tests-usr.bin-tests compattestfile,atf
Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.334 src/usr.bin/make/unit-tests/Makefile:1.335
--- src/usr.bin/make/unit-tests/Makefile:1.334 Tue May 9 20:14:27 2023
+++ src/usr.bin/make/unit-tests/Makefile Wed May 10 13:03:06 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.334 2023/05/09 20:14:27 sjg Exp $
+# $NetBSD: Makefile,v 1.335 2023/05/10 13:03:06 rillig Exp $
#
# Unit tests for make(1)
#
@@ -212,7 +212,6 @@ TESTS+= export
TESTS+= export-all
TESTS+= export-env
TESTS+= export-variants
-TESTS+= forloop
TESTS+= forsubst
TESTS+= gnode-submake
TESTS+= hanoi-include
Index: src/usr.bin/make/unit-tests/directive-for.exp
diff -u src/usr.bin/make/unit-tests/directive-for.exp:1.16 src/usr.bin/make/unit-tests/directive-for.exp:1.17
--- src/usr.bin/make/unit-tests/directive-for.exp:1.16 Tue May 9 19:43:12 2023
+++ src/usr.bin/make/unit-tests/directive-for.exp Wed May 10 13:03:06 2023
@@ -15,16 +15,16 @@ make: "directive-for.mk" line 148: )( )(
make: "directive-for.mk" line 148: ][ ][ ][
make: "directive-for.mk" line 148: }{ }{ }{
make: "directive-for.mk" line 168: invalid character ':' in .for loop variable name
-make: "directive-for.mk" line 174: invalid character '$' in .for loop variable name
-make: "directive-for.mk" line 179: invalid character '$' in .for loop variable name
-make: "directive-for.mk" line 188: Unknown modifier "Z"
-make: "directive-for.mk" line 189: XXX: Not reached word1
-make: "directive-for.mk" line 189: XXX: Not reached word3
-make: "directive-for.mk" line 196: no iteration variables in for
-make: "directive-for.mk" line 222: 1 open conditional
-make: "directive-for.mk" line 238: for-less endfor
-make: "directive-for.mk" line 239: if-less endif
-make: "directive-for.mk" line 247: if-less endif
+make: "directive-for.mk" line 175: invalid character '$' in .for loop variable name
+make: "directive-for.mk" line 187: invalid character '$' in .for loop variable name
+make: "directive-for.mk" line 198: Unknown modifier "Z"
+make: "directive-for.mk" line 199: XXX: Not reached word1
+make: "directive-for.mk" line 199: XXX: Not reached word3
+make: "directive-for.mk" line 206: no iteration variables in for
+make: "directive-for.mk" line 232: 1 open conditional
+make: "directive-for.mk" line 248: for-less endfor
+make: "directive-for.mk" line 249: if-less endif
+make: "directive-for.mk" line 257: if-less endif
For: new loop 2
For: end for 2
For: end for 1
@@ -35,6 +35,7 @@ For: loop body:
endfor
For: end for 1
For: loop body:
+make: "directive-for.mk" line 305: newline-item=(a)
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/directive-for.mk
diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.19 src/usr.bin/make/unit-tests/directive-for.mk:1.20
--- src/usr.bin/make/unit-tests/directive-for.mk:1.19 Tue May 9 19:43:12 2023
+++ src/usr.bin/make/unit-tests/directive-for.mk Wed May 10 13:03:06 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for.mk,v 1.19 2023/05/09 19:43:12 rillig Exp $
+# $NetBSD: directive-for.mk,v 1.20 2023/05/10 13:03:06 rillig Exp $
#
# Tests for the .for directive.
#
@@ -60,7 +60,7 @@ WORDS+= counted
# A noticeable effect of this implementation technique is that the .for
# iteration variables and the normal global variables live in separate
# namespaces and do not influence each other. The "scope" of the .for loop
-# variables is restricted to the current makefile, it does not each over to
+# variables is restricted to the current makefile, it does not reach over to
# any included makefiles.
var= value before
var2= value before
@@ -160,24 +160,34 @@ EXPANSION${plus}= value
# expect-12: ][ ][ ][
# expect-13: }{ }{ }{
-# As of 2020-10-25, the variable names may contain arbitrary characters,
-# except for whitespace. This allows for creative side effects. Hopefully
-# nobody is misusing this "feature".
+# Before 2023-05-09, the variable names could contain arbitrary characters,
+# except for whitespace, allowing for creative side effects, as usual for
+# arbitrary code injection.
var= outer
# expect+1: invalid character ':' in .for loop variable name
.for var:Q in value "quoted"
. info <${var}> <${var:Q}> <${var:Q:Q}>
.endfor
-# The short expression '$$' is preserved, the long expressions are
-# substituted.
+
+# Before 2023-05-09, when variable names could contain '$', the short
+# expression '$$' was preserved, the long expressions were substituted.
# expect+1: invalid character '$' in .for loop variable name
.for $ in value
. info <$$> <${$}> <$($)>
.endfor
-# From https://gnats.netbsd.org/53146.
+
+
+# https://gnats.netbsd.org/53146 mentions the idea of using a dynamic
+# variable name in .for loops, based on some other variable. The .for loops
+# are already tricky enough to understand in detail, even without this
+# possibility, therefore the variable names are restricted to using harmless
+# characters only.
+INDIRECT= direct
# expect+1: invalid character '$' in .for loop variable name
-.for $(FOO) in a b
-. info <$(FOO)> <$(foo)> <$($(FOO))>
+.for $(INDIRECT) in value
+# If the variable name could be chosen dynamically, the iteration variable
+# might have been 'direct', thereby expanding the expression '${direct}'.
+. info <$(INDIRECT)> <$(direct)> <$($(INDIRECT))>
.endfor
@@ -286,3 +296,12 @@ var= outer
. error
. endif
.endfor
+
+
+# Since at least 1993, iteration stops at the first newline.
+# Back then, the .newline variable didn't exist, therefore it was unlikely
+# that a newline ever occurred.
+.for var in a${.newline}b${.newline}c
+. info newline-item=(${var})
+.endfor
+# expect-2: newline-item=(a)