Module Name: src
Committed By: rillig
Date: Mon Dec 14 20:23:50 UTC 2020
Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: cond-eof.exp cond-eof.mk
Log Message:
make(1): add test for parsing the end of a condition
To generate a diff of this commit:
cvs rdiff -u -r1.993 -r1.994 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.249 -r1.250 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/cond-eof.exp \
src/usr.bin/make/unit-tests/cond-eof.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.993 src/distrib/sets/lists/tests/mi:1.994
--- src/distrib/sets/lists/tests/mi:1.993 Sun Dec 13 17:44:31 2020
+++ src/distrib/sets/lists/tests/mi Mon Dec 14 20:23:49 2020
@@ -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
Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.249 src/usr.bin/make/unit-tests/Makefile:1.250
--- src/usr.bin/make/unit-tests/Makefile:1.249 Sun Dec 13 17:44:31 2020
+++ src/usr.bin/make/unit-tests/Makefile Mon Dec 14 20:23:50 2020
@@ -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
Added files:
Index: src/usr.bin/make/unit-tests/cond-eof.exp
diff -u /dev/null src/usr.bin/make/unit-tests/cond-eof.exp:1.1
--- /dev/null Mon Dec 14 20:23:50 2020
+++ src/usr.bin/make/unit-tests/cond-eof.exp Mon Dec 14 20:23:50 2020
@@ -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
Index: src/usr.bin/make/unit-tests/cond-eof.mk
diff -u /dev/null src/usr.bin/make/unit-tests/cond-eof.mk:1.1
--- /dev/null Mon Dec 14 20:23:50 2020
+++ src/usr.bin/make/unit-tests/cond-eof.mk Mon Dec 14 20:23:50 2020
@@ -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