Sat Oct 31 11:30:57 2020 UTC ()
make(1): add test for recursive variable expressions


(rillig)
diff -r1.953 -r1.954 src/distrib/sets/lists/tests/mi
diff -r1.178 -r1.179 src/usr.bin/make/unit-tests/Makefile
diff -r0 -r1.1 src/usr.bin/make/unit-tests/var-recursive.exp
diff -r0 -r1.1 src/usr.bin/make/unit-tests/var-recursive.mk

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

--- src/distrib/sets/lists/tests/mi 2020/10/31 11:06:24 1.953
+++ src/distrib/sets/lists/tests/mi 2020/10/31 11:30:56 1.954
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.953 2020/10/31 11:06:24 rillig Exp $ 1# $NetBSD: mi,v 1.954 2020/10/31 11:30:56 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
@@ -5290,26 +5290,28 @@ @@ -5290,26 +5290,28 @@
5290./usr/tests/usr.bin/make/unit-tests/var-op-append.mk tests-usr.bin-tests compattestfile,atf 5290./usr/tests/usr.bin/make/unit-tests/var-op-append.mk tests-usr.bin-tests compattestfile,atf
5291./usr/tests/usr.bin/make/unit-tests/var-op-assign.exp tests-usr.bin-tests compattestfile,atf 5291./usr/tests/usr.bin/make/unit-tests/var-op-assign.exp tests-usr.bin-tests compattestfile,atf
5292./usr/tests/usr.bin/make/unit-tests/var-op-assign.mk tests-usr.bin-tests compattestfile,atf 5292./usr/tests/usr.bin/make/unit-tests/var-op-assign.mk tests-usr.bin-tests compattestfile,atf
5293./usr/tests/usr.bin/make/unit-tests/var-op-default.exp tests-usr.bin-tests compattestfile,atf 5293./usr/tests/usr.bin/make/unit-tests/var-op-default.exp tests-usr.bin-tests compattestfile,atf
5294./usr/tests/usr.bin/make/unit-tests/var-op-default.mk tests-usr.bin-tests compattestfile,atf 5294./usr/tests/usr.bin/make/unit-tests/var-op-default.mk tests-usr.bin-tests compattestfile,atf
5295./usr/tests/usr.bin/make/unit-tests/var-op-expand.exp tests-usr.bin-tests compattestfile,atf 5295./usr/tests/usr.bin/make/unit-tests/var-op-expand.exp tests-usr.bin-tests compattestfile,atf
5296./usr/tests/usr.bin/make/unit-tests/var-op-expand.mk tests-usr.bin-tests compattestfile,atf 5296./usr/tests/usr.bin/make/unit-tests/var-op-expand.mk tests-usr.bin-tests compattestfile,atf
5297./usr/tests/usr.bin/make/unit-tests/var-op-shell.exp tests-usr.bin-tests compattestfile,atf 5297./usr/tests/usr.bin/make/unit-tests/var-op-shell.exp tests-usr.bin-tests compattestfile,atf
5298./usr/tests/usr.bin/make/unit-tests/var-op-shell.mk tests-usr.bin-tests compattestfile,atf 5298./usr/tests/usr.bin/make/unit-tests/var-op-shell.mk tests-usr.bin-tests compattestfile,atf
5299./usr/tests/usr.bin/make/unit-tests/var-op-sunsh.exp tests-usr.bin-tests compattestfile,atf 5299./usr/tests/usr.bin/make/unit-tests/var-op-sunsh.exp tests-usr.bin-tests compattestfile,atf
5300./usr/tests/usr.bin/make/unit-tests/var-op-sunsh.mk tests-usr.bin-tests compattestfile,atf 5300./usr/tests/usr.bin/make/unit-tests/var-op-sunsh.mk tests-usr.bin-tests compattestfile,atf
5301./usr/tests/usr.bin/make/unit-tests/var-op.exp tests-usr.bin-tests compattestfile,atf 5301./usr/tests/usr.bin/make/unit-tests/var-op.exp tests-usr.bin-tests compattestfile,atf
5302./usr/tests/usr.bin/make/unit-tests/var-op.mk tests-usr.bin-tests compattestfile,atf 5302./usr/tests/usr.bin/make/unit-tests/var-op.mk tests-usr.bin-tests compattestfile,atf
 5303./usr/tests/usr.bin/make/unit-tests/var-recursive.exp tests-usr.bin-tests compattestfile,atf
 5304./usr/tests/usr.bin/make/unit-tests/var-recursive.mk tests-usr.bin-tests compattestfile,atf
5303./usr/tests/usr.bin/make/unit-tests/varcmd.exp tests-usr.bin-tests compattestfile,atf 5305./usr/tests/usr.bin/make/unit-tests/varcmd.exp tests-usr.bin-tests compattestfile,atf
5304./usr/tests/usr.bin/make/unit-tests/varcmd.mk tests-usr.bin-tests compattestfile,atf 5306./usr/tests/usr.bin/make/unit-tests/varcmd.mk tests-usr.bin-tests compattestfile,atf
5305./usr/tests/usr.bin/make/unit-tests/vardebug.exp tests-usr.bin-tests compattestfile,atf 5307./usr/tests/usr.bin/make/unit-tests/vardebug.exp tests-usr.bin-tests compattestfile,atf
5306./usr/tests/usr.bin/make/unit-tests/vardebug.mk tests-usr.bin-tests compattestfile,atf 5308./usr/tests/usr.bin/make/unit-tests/vardebug.mk tests-usr.bin-tests compattestfile,atf
5307./usr/tests/usr.bin/make/unit-tests/varfind.exp tests-usr.bin-tests compattestfile,atf 5309./usr/tests/usr.bin/make/unit-tests/varfind.exp tests-usr.bin-tests compattestfile,atf
5308./usr/tests/usr.bin/make/unit-tests/varfind.mk tests-usr.bin-tests compattestfile,atf 5310./usr/tests/usr.bin/make/unit-tests/varfind.mk tests-usr.bin-tests compattestfile,atf
5309./usr/tests/usr.bin/make/unit-tests/varmisc.exp tests-usr.bin-tests compattestfile,atf 5311./usr/tests/usr.bin/make/unit-tests/varmisc.exp tests-usr.bin-tests compattestfile,atf
5310./usr/tests/usr.bin/make/unit-tests/varmisc.mk tests-usr.bin-tests compattestfile,atf 5312./usr/tests/usr.bin/make/unit-tests/varmisc.mk tests-usr.bin-tests compattestfile,atf
5311./usr/tests/usr.bin/make/unit-tests/varmod-assign.exp tests-usr.bin-tests compattestfile,atf 5313./usr/tests/usr.bin/make/unit-tests/varmod-assign.exp tests-usr.bin-tests compattestfile,atf
5312./usr/tests/usr.bin/make/unit-tests/varmod-assign.mk tests-usr.bin-tests compattestfile,atf 5314./usr/tests/usr.bin/make/unit-tests/varmod-assign.mk tests-usr.bin-tests compattestfile,atf
5313./usr/tests/usr.bin/make/unit-tests/varmod-defined.exp tests-usr.bin-tests compattestfile,atf 5315./usr/tests/usr.bin/make/unit-tests/varmod-defined.exp tests-usr.bin-tests compattestfile,atf
5314./usr/tests/usr.bin/make/unit-tests/varmod-defined.mk tests-usr.bin-tests compattestfile,atf 5316./usr/tests/usr.bin/make/unit-tests/varmod-defined.mk tests-usr.bin-tests compattestfile,atf
5315./usr/tests/usr.bin/make/unit-tests/varmod-edge.exp tests-usr.bin-tests compattestfile,atf 5317./usr/tests/usr.bin/make/unit-tests/varmod-edge.exp tests-usr.bin-tests compattestfile,atf

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

--- src/usr.bin/make/unit-tests/Makefile 2020/10/31 11:06:24 1.178
+++ src/usr.bin/make/unit-tests/Makefile 2020/10/31 11:30:57 1.179
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.178 2020/10/31 11:06:24 rillig Exp $ 1# $NetBSD: Makefile,v 1.179 2020/10/31 11:30:57 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
@@ -268,26 +268,27 @@ TESTS+= use-inference @@ -268,26 +268,27 @@ TESTS+= use-inference
268TESTS+= var-class 268TESTS+= var-class
269TESTS+= var-class-cmdline 269TESTS+= var-class-cmdline
270TESTS+= var-class-env 270TESTS+= var-class-env
271TESTS+= var-class-global 271TESTS+= var-class-global
272TESTS+= var-class-local 272TESTS+= var-class-local
273TESTS+= var-class-local-legacy 273TESTS+= var-class-local-legacy
274TESTS+= var-op 274TESTS+= var-op
275TESTS+= var-op-append 275TESTS+= var-op-append
276TESTS+= var-op-assign 276TESTS+= var-op-assign
277TESTS+= var-op-default 277TESTS+= var-op-default
278TESTS+= var-op-expand 278TESTS+= var-op-expand
279TESTS+= var-op-shell 279TESTS+= var-op-shell
280TESTS+= var-op-sunsh 280TESTS+= var-op-sunsh
 281TESTS+= var-recursive
281TESTS+= varcmd 282TESTS+= varcmd
282TESTS+= vardebug 283TESTS+= vardebug
283TESTS+= varfind 284TESTS+= varfind
284TESTS+= varmisc 285TESTS+= varmisc
285TESTS+= varmod 286TESTS+= varmod
286TESTS+= varmod-assign 287TESTS+= varmod-assign
287TESTS+= varmod-defined 288TESTS+= varmod-defined
288TESTS+= varmod-edge 289TESTS+= varmod-edge
289TESTS+= varmod-exclam-shell 290TESTS+= varmod-exclam-shell
290TESTS+= varmod-extension 291TESTS+= varmod-extension
291TESTS+= varmod-gmtime 292TESTS+= varmod-gmtime
292TESTS+= varmod-hash 293TESTS+= varmod-hash
293TESTS+= varmod-head 294TESTS+= varmod-head

File Added: src/usr.bin/make/unit-tests/var-recursive.exp
make: "var-recursive.mk" line 20: still there
Variable DIRECT is recursive.

make: stopped in unit-tests
Variable INDIRECT1 is recursive.

make: stopped in unit-tests
make: "var-recursive.mk" line 35: ok
exit status 0

File Added: src/usr.bin/make/unit-tests/var-recursive.mk
# $NetBSD: var-recursive.mk,v 1.1 2020/10/31 11:30:57 rillig Exp $
#
# Tests for variable expressions that refer to themselves and thus
# cannot be evaluated.

TESTS=	direct indirect conditional

# Since make exits immediately when it detects a recursive expression,
# the actual tests are run in sub-makes.
TEST?=	# none
.if ${TEST} == ""
all:
.for test in ${TESTS}
	@${.MAKE} -f ${MAKEFILE} TEST=${test} || :
.endfor

.elif ${TEST} == direct

DIRECT=	${DIRECT}	# Defining a recursive variable is not yet an error.
.  info still there	# Therefore this line is printed.
.  info ${DIRECT}	# But expanding the variable is an error.

.elif ${TEST} == indirect

# The chain of variables that refer to each other may be long.
INDIRECT1=	${INDIRECT2}
INDIRECT2=	${INDIRECT1}
.  info ${INDIRECT1}

.elif ${TEST} == conditional

# The variable refers to itself, but only in the branch of a condition that
# is never satisfied and is thus not evaluated.
CONDITIONAL=	${1:?ok:${CONDITIONAL}}
.  info ${CONDITIONAL}

.else
.  error Unknown test "${TEST}"
.endif

all: