make(1): add test for parsing the end of a condition

This commit is contained in:
rillig 2020-12-14 20:23:49 +00:00
parent 7ef7e7e9a9
commit 22b3e4f8b0
4 changed files with 33 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.993 2020/12/13 17:44:31 rillig Exp $
# $NetBSD: mi,v 1.994 2020/12/14 20:23:49 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -4850,6 +4850,8 @@
./usr/tests/usr.bin/make/unit-tests/cond-cmp-string.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/cond-cmp-unary.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/cond-cmp-unary.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/cond-eof.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/cond-eof.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/cond-func-commands.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/cond-func-commands.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/cond-func-defined.exp tests-usr.bin-tests compattestfile,atf

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.249 2020/12/13 17:44:31 rillig Exp $
# $NetBSD: Makefile,v 1.250 2020/12/14 20:23:50 rillig Exp $
#
# Unit tests for make(1)
#
@ -56,6 +56,7 @@ TESTS+= cond-cmp-numeric-lt
TESTS+= cond-cmp-numeric-ne
TESTS+= cond-cmp-string
TESTS+= cond-cmp-unary
TESTS+= cond-eof
TESTS+= cond-func
TESTS+= cond-func-commands
TESTS+= cond-func-defined

View File

@ -0,0 +1,9 @@
side effect
make: "cond-eof.mk" line 14: Malformed conditional (0 ${SIDE_EFFECT})
side effect
make: "cond-eof.mk" line 16: Malformed conditional (1 ${SIDE_EFFECT})
side effect
make: "cond-eof.mk" line 18: Malformed conditional ((0) ${SIDE_EFFECT})
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1

View File

@ -0,0 +1,19 @@
# $NetBSD: cond-eof.mk,v 1.1 2020/12/14 20:23:50 rillig Exp $
#
# Tests for parsing conditions, especially the end of such conditions, which
# are represented as the token TOK_EOF.
SIDE_EFFECT= ${:!echo 'side effect' 1>&2!}
# In the following conditions, ${SIDE_EFFECT} is the position of the first
# parse error. It is always fully evaluated, even if it were not necessary
# to expand the variable expression. This is because these syntax errors are
# an edge case that does not occur during normal operation, therefore there
# is no need to optimize for this case, and it would slow down the common
# case as well.
.if 0 ${SIDE_EFFECT}
.endif
.if 1 ${SIDE_EFFECT}
.endif
.if (0) ${SIDE_EFFECT}
.endif