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 the function d...



details:   https://anonhg.NetBSD.org/src/rev/2e316434249d
branches:  trunk
changeset: 942807:2e316434249d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Aug 20 17:23:43 2020 +0000

description:
make(1): add test for the function defined(...)

diffstat:

 usr.bin/make/unit-tests/cond-func-defined.exp |   6 ++++-
 usr.bin/make/unit-tests/cond-func-defined.mk  |  29 +++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 3 deletions(-)

diffs (49 lines):

diff -r 3c2efa39d5f6 -r 2e316434249d usr.bin/make/unit-tests/cond-func-defined.exp
--- a/usr.bin/make/unit-tests/cond-func-defined.exp     Thu Aug 20 17:13:05 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-func-defined.exp     Thu Aug 20 17:23:43 2020 +0000
@@ -1,1 +1,5 @@
-exit status 0
+make: "cond-func-defined.mk" line 25: warning: Missing closing parenthesis for defined()
+make: "cond-func-defined.mk" line 25: Malformed conditional (!defined(A B))
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r 3c2efa39d5f6 -r 2e316434249d usr.bin/make/unit-tests/cond-func-defined.mk
--- a/usr.bin/make/unit-tests/cond-func-defined.mk      Thu Aug 20 17:13:05 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-func-defined.mk      Thu Aug 20 17:23:43 2020 +0000
@@ -1,8 +1,33 @@
-# $NetBSD: cond-func-defined.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: cond-func-defined.mk,v 1.3 2020/08/20 17:23:43 rillig Exp $
 #
 # Tests for the defined() function in .if conditions.
 
-# TODO: Implementation
+DEF=           defined
+${:UA B}=      variable name with spaces
+
+.if !defined(DEF)
+.error
+.endif
+
+# Horizontal whitespace after the opening parenthesis is ignored.
+.if !defined(  DEF)
+.error
+.endif
+
+# Horizontal whitespace before the closing parenthesis is ignored.
+.if !defined(DEF       )
+.error
+.endif
+
+# The argument of a function must not directly contain whitespace.
+.if !defined(A B)
+.error
+.endif
+
+# If necessary, the whitespace can be generated by a variable expression.
+.if !defined(${:UA B})
+.error
+.endif
 
 all:
        @:;



Home | Main Index | Thread Index | Old Index