Sun Jun 28 09:42:41 2020 UTC ()
make(1): demonstrate bug when evaluating conditions


(rillig)
diff -r1.861 -r1.862 src/distrib/sets/lists/tests/mi
diff -r1.58 -r1.59 src/usr.bin/make/unit-tests/Makefile
diff -r0 -r1.1 src/usr.bin/make/unit-tests/cond-short.exp
diff -r0 -r1.1 src/usr.bin/make/unit-tests/cond-short.mk

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

--- src/distrib/sets/lists/tests/mi 2020/06/27 13:53:43 1.861
+++ src/distrib/sets/lists/tests/mi 2020/06/28 09:42:40 1.862
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.861 2020/06/27 13:53:43 jruoho Exp $ 1# $NetBSD: mi,v 1.862 2020/06/28 09:42:40 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
@@ -4479,26 +4479,28 @@ @@ -4479,26 +4479,28 @@
4479./usr/tests/usr.bin/make/d_ternary.mk tests-obsolete obsolete,atf 4479./usr/tests/usr.bin/make/d_ternary.mk tests-obsolete obsolete,atf
4480./usr/tests/usr.bin/make/d_ternary.out tests-obsolete obsolete,atf 4480./usr/tests/usr.bin/make/d_ternary.out tests-obsolete obsolete,atf
4481./usr/tests/usr.bin/make/d_unmatchedvarparen.mk tests-obsolete obsolete,atf 4481./usr/tests/usr.bin/make/d_unmatchedvarparen.mk tests-obsolete obsolete,atf
4482./usr/tests/usr.bin/make/d_unmatchedvarparen.out tests-obsolete obsolete,atf 4482./usr/tests/usr.bin/make/d_unmatchedvarparen.out tests-obsolete obsolete,atf
4483./usr/tests/usr.bin/make/d_varcmd.mk tests-obsolete obsolete,atf 4483./usr/tests/usr.bin/make/d_varcmd.mk tests-obsolete obsolete,atf
4484./usr/tests/usr.bin/make/d_varcmd.out tests-obsolete obsolete,atf 4484./usr/tests/usr.bin/make/d_varcmd.out tests-obsolete obsolete,atf
4485./usr/tests/usr.bin/make/t_make tests-usr.bin-tests compattestfile,atf 4485./usr/tests/usr.bin/make/t_make tests-usr.bin-tests compattestfile,atf
4486./usr/tests/usr.bin/make/unit-tests tests-usr.bin-tests compattestfile,atf 4486./usr/tests/usr.bin/make/unit-tests tests-usr.bin-tests compattestfile,atf
4487./usr/tests/usr.bin/make/unit-tests/Makefile tests-usr.bin-tests compattestfile,atf 4487./usr/tests/usr.bin/make/unit-tests/Makefile tests-usr.bin-tests compattestfile,atf
4488./usr/tests/usr.bin/make/unit-tests/comment.exp tests-usr.bin-tests compattestfile,atf 4488./usr/tests/usr.bin/make/unit-tests/comment.exp tests-usr.bin-tests compattestfile,atf
4489./usr/tests/usr.bin/make/unit-tests/comment.mk tests-usr.bin-tests compattestfile,atf 4489./usr/tests/usr.bin/make/unit-tests/comment.mk tests-usr.bin-tests compattestfile,atf
4490./usr/tests/usr.bin/make/unit-tests/cond-late.exp tests-usr.bin-tests compattestfile,atf 4490./usr/tests/usr.bin/make/unit-tests/cond-late.exp tests-usr.bin-tests compattestfile,atf
4491./usr/tests/usr.bin/make/unit-tests/cond-late.mk tests-usr.bin-tests compattestfile,atf 4491./usr/tests/usr.bin/make/unit-tests/cond-late.mk tests-usr.bin-tests compattestfile,atf
 4492./usr/tests/usr.bin/make/unit-tests/cond-short.exp tests-usr.bin-tests compattestfile,atf
 4493./usr/tests/usr.bin/make/unit-tests/cond-short.mk tests-usr.bin-tests compattestfile,atf
4492./usr/tests/usr.bin/make/unit-tests/cond1.exp tests-usr.bin-tests compattestfile,atf 4494./usr/tests/usr.bin/make/unit-tests/cond1.exp tests-usr.bin-tests compattestfile,atf
4493./usr/tests/usr.bin/make/unit-tests/cond1.mk tests-usr.bin-tests compattestfile,atf 4495./usr/tests/usr.bin/make/unit-tests/cond1.mk tests-usr.bin-tests compattestfile,atf
4494./usr/tests/usr.bin/make/unit-tests/cond2.exp tests-usr.bin-tests compattestfile,atf 4496./usr/tests/usr.bin/make/unit-tests/cond2.exp tests-usr.bin-tests compattestfile,atf
4495./usr/tests/usr.bin/make/unit-tests/cond2.mk tests-usr.bin-tests compattestfile,atf 4497./usr/tests/usr.bin/make/unit-tests/cond2.mk tests-usr.bin-tests compattestfile,atf
4496./usr/tests/usr.bin/make/unit-tests/dollar.exp tests-usr.bin-tests compattestfile,atf 4498./usr/tests/usr.bin/make/unit-tests/dollar.exp tests-usr.bin-tests compattestfile,atf
4497./usr/tests/usr.bin/make/unit-tests/dollar.mk tests-usr.bin-tests compattestfile,atf 4499./usr/tests/usr.bin/make/unit-tests/dollar.mk tests-usr.bin-tests compattestfile,atf
4498./usr/tests/usr.bin/make/unit-tests/doterror.exp tests-usr.bin-tests compattestfile,atf 4500./usr/tests/usr.bin/make/unit-tests/doterror.exp tests-usr.bin-tests compattestfile,atf
4499./usr/tests/usr.bin/make/unit-tests/doterror.mk tests-usr.bin-tests compattestfile,atf 4501./usr/tests/usr.bin/make/unit-tests/doterror.mk tests-usr.bin-tests compattestfile,atf
4500./usr/tests/usr.bin/make/unit-tests/dotwait.exp tests-usr.bin-tests compattestfile,atf 4502./usr/tests/usr.bin/make/unit-tests/dotwait.exp tests-usr.bin-tests compattestfile,atf
4501./usr/tests/usr.bin/make/unit-tests/dotwait.mk tests-usr.bin-tests compattestfile,atf 4503./usr/tests/usr.bin/make/unit-tests/dotwait.mk tests-usr.bin-tests compattestfile,atf
4502./usr/tests/usr.bin/make/unit-tests/error.exp tests-usr.bin-tests compattestfile,atf 4504./usr/tests/usr.bin/make/unit-tests/error.exp tests-usr.bin-tests compattestfile,atf
4503./usr/tests/usr.bin/make/unit-tests/error.mk tests-usr.bin-tests compattestfile,atf 4505./usr/tests/usr.bin/make/unit-tests/error.mk tests-usr.bin-tests compattestfile,atf
4504./usr/tests/usr.bin/make/unit-tests/escape.exp tests-usr.bin-tests compattestfile,atf 4506./usr/tests/usr.bin/make/unit-tests/escape.exp tests-usr.bin-tests compattestfile,atf

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

--- src/usr.bin/make/unit-tests/Makefile 2020/05/17 12:36:26 1.58
+++ src/usr.bin/make/unit-tests/Makefile 2020/06/28 09:42:40 1.59
@@ -1,38 +1,39 @@ @@ -1,38 +1,39 @@
1# $NetBSD: Makefile,v 1.58 2020/05/17 12:36:26 rillig Exp $ 1# $NetBSD: Makefile,v 1.59 2020/06/28 09:42:40 rillig Exp $
2# 2#
3# Unit tests for make(1) 3# Unit tests for make(1)
4# The main targets are: 4# The main targets are:
5#  5#
6# all: run all the tests 6# all: run all the tests
7# test: run 'all', and compare to expected results 7# test: run 'all', and compare to expected results
8# accept: move generated output to expected results 8# accept: move generated output to expected results
9# 9#
10# Adding a test case.  10# Adding a test case.
11# Each feature should get its own set of tests in its own suitably 11# Each feature should get its own set of tests in its own suitably
12# named makefile (*.mk), with its own set of expected results (*.exp), 12# named makefile (*.mk), with its own set of expected results (*.exp),
13# and it should be added to the TESTNAMES list. 13# and it should be added to the TESTNAMES list.
14#  14#
15 15
16.MAIN: all 16.MAIN: all
17 17
18UNIT_TESTS:= ${.PARSEDIR} 18UNIT_TESTS:= ${.PARSEDIR}
19.PATH: ${UNIT_TESTS} 19.PATH: ${UNIT_TESTS}
20 20
21# Each test is in a sub-makefile. 21# Each test is in a sub-makefile.
22# Keep the list sorted. 22# Keep the list sorted.
23TESTNAMES= \ 23TESTNAMES= \
24 comment \ 24 comment \
25 cond-late \ 25 cond-late \
 26 cond-short \
26 cond1 \ 27 cond1 \
27 cond2 \ 28 cond2 \
28 dollar \ 29 dollar \
29 doterror \ 30 doterror \
30 dotwait \ 31 dotwait \
31 error \ 32 error \
32 export \ 33 export \
33 export-all \ 34 export-all \
34 export-env \ 35 export-env \
35 forloop \ 36 forloop \
36 forsubst \ 37 forsubst \
37 hash \ 38 hash \
38 include-main \ 39 include-main \

File Added: src/usr.bin/make/unit-tests/cond-short.exp
unexpected and
expected and
unexpected or
expected or
exit status 0

File Added: src/usr.bin/make/unit-tests/cond-short.mk
# $NetBSD: cond-short.mk,v 1.1 2020/06/28 09:42:40 rillig Exp $
#
# Demonstrates that in conditions, the right-hand side of an && or ||
# is evaluated even though it cannot influence the result.
#
# This is unexpected for several reasons:
#
# 1.  The manual page says: "bmake will only evaluate a conditional as
#     far as is necessary to determine its value."
#
# 2.  It differs from the way that these operators are evaluated in
#     almost all other programming languages.
#
# 3.  In cond.c there are lots of doEval variables.
#

.if 0 && ${echo "unexpected and" 1>&2 :L:sh}
.endif

.if 1 && ${echo "expected and" 1>&2 :L:sh}
.endif

.if 1 || ${echo "unexpected or" 1>&2 :L:sh}
.endif

.if 0 || ${echo "expected or" 1>&2 :L:sh}
.endif

# The following paragraphs demonstrate the workaround.

.if 0
.  if ${echo "unexpected nested and" 1>&2 :L:sh}
.  endif
.endif

.if 1
.elif ${echo "unexpected nested or" 1>&2 :L:sh}
.endif

all:
	@:;: