Module Name:    src
Committed By:   sjg
Date:           Tue Jun 19 23:25:53 UTC 2012

Modified Files:
        src/usr.bin/make/unit-tests: Makefile test.exp
Added Files:
        src/usr.bin/make/unit-tests: forloop

Log Message:
Add unit-tests for .for


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/forloop
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/make/unit-tests/test.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.33 src/usr.bin/make/unit-tests/Makefile:1.34
--- src/usr.bin/make/unit-tests/Makefile:1.33	Thu Sep 29 23:38:04 2011
+++ src/usr.bin/make/unit-tests/Makefile	Tue Jun 19 23:25:53 2012
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.33 2011/09/29 23:38:04 sjg Exp $
+# $NetBSD: Makefile,v 1.34 2012/06/19 23:25:53 sjg Exp $
 #
 # Unit tests for make(1)
 # The main targets are:
@@ -26,6 +26,7 @@ SUBFILES= \
 	export-all \
 	doterror \
 	dotwait \
+	forloop \
 	forsubst \
 	hash \
 	misc \

Index: src/usr.bin/make/unit-tests/test.exp
diff -u src/usr.bin/make/unit-tests/test.exp:1.39 src/usr.bin/make/unit-tests/test.exp:1.40
--- src/usr.bin/make/unit-tests/test.exp:1.39	Thu Sep 29 23:38:04 2011
+++ src/usr.bin/make/unit-tests/test.exp	Tue Jun 19 23:25:53 2012
@@ -80,6 +80,24 @@ make: Graph cycles through `cycle.2.98'
 make: Graph cycles through `cycle.2.97'
 cycle.1.99
 cycle.1.99
+x=one
+x="two and three"
+x=four
+x="five"
+x=-I/this
+x=-I"This or that"
+x=-Ithat
+x="-DTHIS=\"this and that\""
+cfl=-I/this -I"This or that" -Ithat "-DTHIS=\"this and that\""
+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" line 38: Wrong number of words (9) in .for substitution list with 2 vars
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+OK
 .for with :S;... OK
 b2af338b
 3360ac65

Added files:

Index: src/usr.bin/make/unit-tests/forloop
diff -u /dev/null src/usr.bin/make/unit-tests/forloop:1.1
--- /dev/null	Tue Jun 19 23:25:53 2012
+++ src/usr.bin/make/unit-tests/forloop	Tue Jun 19 23:25:53 2012
@@ -0,0 +1,45 @@
+# $Id: forloop,v 1.1 2012/06/19 23:25:53 sjg Exp $
+
+all: for-loop
+
+LIST = one "two and three" four "five"
+
+.if make(for-fail)
+for-fail:
+
+XTRA_LIST = xtra
+.else
+
+.for x in ${LIST}
+X!= echo 'x=$x' >&2; echo
+.endfor
+
+CFL = -I/this -I"This or that" -Ithat "-DTHIS=\"this and that\""
+cfl=
+.for x in ${CFL}
+X!= echo 'x=$x' >&2; echo
+.if empty(cfl)
+cfl= $x
+.else
+cfl+= $x
+.endif
+.endfor
+X!= echo 'cfl=${cfl}' >&2; echo
+
+.if ${cfl} != ${CFL}
+.error ${.newline}'${cfl}' != ${.newline}'${CFL}'
+.endif
+
+.for a b in ${EMPTY}
+X!= echo 'a=$a b=$b' >&2; echo
+.endfor
+.endif
+
+.for a b in ${LIST} ${LIST:tu} ${XTRA_LIST}
+X!= echo 'a=$a b=$b' >&2; echo
+.endfor
+
+for-loop:
+	@echo We expect an error next:
+	@(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} for-fail) && \
+	{ echo "Oops that should have failed!"; exit 1; } || echo OK

Reply via email to