Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add test for parsing the en...



details:   https://anonhg.NetBSD.org/src/rev/3ae8631e5edf
branches:  trunk
changeset: 947516:3ae8631e5edf
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Dec 14 20:23:49 2020 +0000

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

diffstat:

 distrib/sets/lists/tests/mi          |   4 +++-
 usr.bin/make/unit-tests/Makefile     |   3 ++-
 usr.bin/make/unit-tests/cond-eof.exp |   9 +++++++++
 usr.bin/make/unit-tests/cond-eof.mk  |  19 +++++++++++++++++++
 4 files changed, 33 insertions(+), 2 deletions(-)

diffs (71 lines):

diff -r f6f13c83889c -r 3ae8631e5edf distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Mon Dec 14 19:42:51 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Mon Dec 14 20:23:49 2020 +0000
@@ -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
diff -r f6f13c83889c -r 3ae8631e5edf usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Mon Dec 14 19:42:51 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Mon Dec 14 20:23:49 2020 +0000
@@ -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-ne
 TESTS+=                cond-cmp-string
 TESTS+=                cond-cmp-unary
+TESTS+=                cond-eof
 TESTS+=                cond-func
 TESTS+=                cond-func-commands
 TESTS+=                cond-func-defined
diff -r f6f13c83889c -r 3ae8631e5edf usr.bin/make/unit-tests/cond-eof.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/cond-eof.exp      Mon Dec 14 20:23:49 2020 +0000
@@ -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
diff -r f6f13c83889c -r 3ae8631e5edf usr.bin/make/unit-tests/cond-eof.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/cond-eof.mk       Mon Dec 14 20:23:49 2020 +0000
@@ -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



Home | Main Index | Thread Index | Old Index