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 usr.bin/make: add test case for lazy...



details:   https://anonhg.NetBSD.org/src/rev/7cb23dba0de6
branches:  trunk
changeset: 971612:7cb23dba0de6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Apr 29 23:15:21 2020 +0000

description:
usr.bin/make: add test case for lazy conditions

diffstat:

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

diffs (68 lines):

diff -r 3a6e52662da5 -r 7cb23dba0de6 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Wed Apr 29 22:17:38 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Wed Apr 29 23:15:21 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.837 2020/04/26 18:53:32 thorpej Exp $
+# $NetBSD: mi,v 1.838 2020/04/29 23:15:22 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4462,6 +4462,8 @@
 ./usr/tests/usr.bin/make/unit-tests/Makefile   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/comment.exp        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/comment.mk tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/cond-late.exp      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/cond-late.mk       tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cond1.exp  tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cond1.mk   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cond2.exp  tests-usr.bin-tests     compattestfile,atf
diff -r 3a6e52662da5 -r 7cb23dba0de6 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Wed Apr 29 22:17:38 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Wed Apr 29 23:15:21 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.54 2019/11/30 00:38:51 rillig Exp $
+# $NetBSD: Makefile,v 1.55 2020/04/29 23:15:21 rillig Exp $
 #
 # Unit tests for make(1)
 # The main targets are:
@@ -22,6 +22,7 @@
 # Keep the list sorted.
 TESTNAMES= \
        comment \
+       cond-late \
        cond1 \
        cond2 \
        error \
diff -r 3a6e52662da5 -r 7cb23dba0de6 usr.bin/make/unit-tests/cond-late.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/cond-late.exp     Wed Apr 29 23:15:21 2020 +0000
@@ -0,0 +1,2 @@
+yes
+no
diff -r 3a6e52662da5 -r 7cb23dba0de6 usr.bin/make/unit-tests/cond-late.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/cond-late.mk      Wed Apr 29 23:15:21 2020 +0000
@@ -0,0 +1,23 @@
+# $NetBSD: cond-late.mk,v 1.1 2020/04/29 23:15:21 rillig Exp $
+#
+# Using the :? modifier, variable expressions can contain conditional
+# expressions that are evaluated late.  Any variables appearing in these
+# conditions are expanded before parsing the condition.  This is
+# different from many other places.
+#
+# Because of this, variables that are used in these lazy conditions
+# should not contain double-quotes, or the parser will probably fail.
+#
+# They should also not contain operators like == or <, since these are
+# actually interpreted as these operators. This is demonstrated below.
+#
+# If the order of evaluation were to change to first parse the condition
+# and then expand the variables, the output would change from the
+# current "yes no" to "yes yes", since both variables are non-empty.
+
+COND.true=     "yes" == "yes"
+COND.false=    "yes" != "yes"
+
+all:
+       @echo ${ ${COND.true} :?yes:no}
+       @echo ${ ${COND.false} :?yes:no}



Home | Main Index | Thread Index | Old Index