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



details:   https://anonhg.NetBSD.org/src/rev/a699bdbf2226
branches:  trunk
changeset: 932176:a699bdbf2226
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri May 01 16:29:34 2020 +0000

description:
usr.bin/make: add test demonstrating that .for stops at newline

diffstat:

 usr.bin/make/unit-tests/forloop.exp |   3 ++-
 usr.bin/make/unit-tests/forloop.mk  |  12 ++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diffs (44 lines):

diff -r 81706683befb -r a699bdbf2226 usr.bin/make/unit-tests/forloop.exp
--- a/usr.bin/make/unit-tests/forloop.exp       Fri May 01 16:26:41 2020 +0000
+++ b/usr.bin/make/unit-tests/forloop.exp       Fri May 01 16:29:34 2020 +0000
@@ -7,12 +7,13 @@
 x=-Ithat
 x="-DTHIS=\"this and that\""
 cfl=-I/this -I"This or that" -Ithat "-DTHIS=\"this and that\""
+newline-item=(a)
 a=one b="two and three"
 a=four b="five"
 a=ONE b="TWO AND THREE"
 a=FOUR b="FIVE"
 We expect an error next:
-make: "forloop.mk" line 38: Wrong number of words (9) in .for substitution list with 2 vars
+make: "forloop.mk" line 46: Wrong number of words (9) in .for substitution list with 2 vars
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 OK
diff -r 81706683befb -r a699bdbf2226 usr.bin/make/unit-tests/forloop.mk
--- a/usr.bin/make/unit-tests/forloop.mk        Fri May 01 16:26:41 2020 +0000
+++ b/usr.bin/make/unit-tests/forloop.mk        Fri May 01 16:29:34 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: forloop.mk,v 1.1 2014/08/21 13:44:51 apb Exp $
+# $Id: forloop.mk,v 1.2 2020/05/01 16:29:34 rillig Exp $
 
 all: for-loop
 
@@ -33,7 +33,15 @@
 .for a b in ${EMPTY}
 X!= echo 'a=$a b=$b' >&2; echo
 .endfor
-.endif
+
+# Since at least 1993, iteration stops at the first newline.
+# Back then, the .newline variable didn't exist, therefore it was unlikely
+# that a newline ever occured.
+.for var in a${.newline}b${.newline}c
+X!= echo 'newline-item=('${var:Q}')' 1>&2; echo
+.endfor
+
+.endif # for-fail
 
 .for a b in ${LIST} ${LIST:tu} ${XTRA_LIST}
 X!= echo 'a=$a b=$b' >&2; echo



Home | Main Index | Thread Index | Old Index