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): demonstrate missing error h...



details:   https://anonhg.NetBSD.org/src/rev/dc23f25dc8f8
branches:  trunk
changeset: 958786:dc23f25dc8f8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jan 19 18:09:12 2021 +0000

description:
make(1): demonstrate missing error handling for malformed conditions

diffstat:

 usr.bin/make/unit-tests/cond-op.exp |   4 ++++
 usr.bin/make/unit-tests/cond-op.mk  |  36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 1 deletions(-)

diffs (63 lines):

diff -r ab0a3fe0802d -r dc23f25dc8f8 usr.bin/make/unit-tests/cond-op.exp
--- a/usr.bin/make/unit-tests/cond-op.exp       Tue Jan 19 17:57:07 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-op.exp       Tue Jan 19 18:09:12 2021 +0000
@@ -11,6 +11,10 @@
 make: "cond-op.mk" line 93: 1 0 1   =>   1               1             1
 make: "cond-op.mk" line 93: 1 1 0   =>   0               1             1
 make: "cond-op.mk" line 93: 1 1 1   =>   1               1             1
+make: "cond-op.mk" line 104: Malformed conditional (1 &&)
+make: "cond-op.mk" line 115: Missing argument for ".error"
+make: "cond-op.mk" line 121: Missing argument for ".error"
+make: "cond-op.mk" line 129: Malformed conditional (0 ||)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r ab0a3fe0802d -r dc23f25dc8f8 usr.bin/make/unit-tests/cond-op.mk
--- a/usr.bin/make/unit-tests/cond-op.mk        Tue Jan 19 17:57:07 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-op.mk        Tue Jan 19 18:09:12 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op.mk,v 1.10 2020/11/15 14:58:14 rillig Exp $
+# $NetBSD: cond-op.mk,v 1.11 2021/01/19 18:09:12 rillig Exp $
 #
 # Tests for operators like &&, ||, ! in .if conditions.
 #
@@ -98,5 +98,39 @@
 .  endfor
 .endfor
 
+# This condition is obviously malformed.  It is properly detected and also
+# was properly detected before 2021-01-19, but only because the left hand
+# side of the '&&' evaluated to true.
+.if 1 &&
+.  error
+.else
+.  error
+.endif
+
+# FIXME: Don't accept this condition as syntactically valid.
+# FIXME: CondParser_Factor, (void).
+.if 0 &&
+.  error
+.else
+.  error
+.endif
+
+# FIXME: Don't accept this condition as syntactically valid.
+# FIXME: CondParser_Expr, (void).
+.if 1 ||
+.  error
+.else
+.  error
+.endif
+
+# This condition is obviously malformed.  It is properly detected and also
+# was properly detected before 2021-01-19, but only because the left hand
+# side of the '||' evaluated to false.
+.if 0 ||
+.  error
+.else
+.  error
+.endif
+
 all:
        @:;



Home | Main Index | Thread Index | Old Index