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 tests demonstrating bug...



details:   https://anonhg.NetBSD.org/src/rev/c87dee8ceee3
branches:  trunk
changeset: 1016202:c87dee8ceee3
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Nov 11 07:30:11 2020 +0000

description:
make(1): add tests demonstrating bugs in TryParseNumber and EvalNotEmpty

diffstat:

 usr.bin/make/unit-tests/cond-cmp-unary.exp |   1 +
 usr.bin/make/unit-tests/cond-cmp-unary.mk  |  17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletions(-)

diffs (42 lines):

diff -r 4574a7d3d3b8 -r c87dee8ceee3 usr.bin/make/unit-tests/cond-cmp-unary.exp
--- a/usr.bin/make/unit-tests/cond-cmp-unary.exp        Wed Nov 11 07:13:42 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-cmp-unary.exp        Wed Nov 11 07:30:11 2020 +0000
@@ -1,1 +1,2 @@
+make: "cond-cmp-unary.mk" line 53: This is only reached because of a bug in EvalNotEmpty.
 exit status 0
diff -r 4574a7d3d3b8 -r c87dee8ceee3 usr.bin/make/unit-tests/cond-cmp-unary.mk
--- a/usr.bin/make/unit-tests/cond-cmp-unary.mk Wed Nov 11 07:13:42 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-cmp-unary.mk Wed Nov 11 07:30:11 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-cmp-unary.mk,v 1.1 2020/09/14 06:22:59 rillig Exp $
+# $NetBSD: cond-cmp-unary.mk,v 1.2 2020/11/11 07:30:11 rillig Exp $
 #
 # Tests for unary comparisons in .if conditions, that is, comparisons with
 # a single operand.  If the operand is a number, it is compared to zero,
@@ -25,6 +25,9 @@
 .endif
 
 # The empty string may come from a variable expression.
+#
+# XXX: As of 2020-11-11, this empty string is interpreted "as a number" in
+# EvalNotEmpty, which is plain wrong.  The bug is in TryParseNumber.
 .if ${:U}
 .  error
 .endif
@@ -40,4 +43,16 @@
 .  error
 .endif
 
+# A string of whitespace should evaluate to false.
+#
+# XXX: As of 2020-11-11, the implementation in EvalNotEmpty does not skip
+# whitespace before testing for the end.  This was probably an oversight in
+# a commit from 1992-04-15 saying "A variable is empty when it just contains
+# spaces".
+.if ${:U   }
+.  info This is only reached because of a bug in EvalNotEmpty.
+.else
+.  error
+.endif
+
 all: # nothing



Home | Main Index | Thread Index | Old Index