Module Name: src
Committed By: rillig
Date: Mon Aug 31 17:32:13 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: varmod-unique.exp varmod-unique.mk
Log Message:
make(1): add test for the currently broken :u variable modifier
The :u modifier had been broken in var.c 1.479 from 2020.08.30.19.56.02.
The code that implements the :u modifier was well-covered in the unit
tests, except for the single line that actually deals with adjacent
duplicate words.
The "refactoring" commit that replaced brk_string with Str_Words had not
taken into account that the number of words (in ac) had to be passed to
WordList_JoinFree. Instead, the number of words was always preserved,
and the words at the end were therefore duplicated in the result.
The fix for this bug will be in the follow-up commit.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-unique.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-unique.mk
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/varmod-unique.exp
diff -u src/usr.bin/make/unit-tests/varmod-unique.exp:1.1 src/usr.bin/make/unit-tests/varmod-unique.exp:1.2
--- src/usr.bin/make/unit-tests/varmod-unique.exp:1.1 Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/varmod-unique.exp Mon Aug 31 17:32:13 2020
@@ -1 +1,7 @@
+make: "varmod-unique.mk" line 11: warning: The :u modifier must merge adjacent duplicate words.
+make: "varmod-unique.mk" line 13: warning: FIXME
+make: "varmod-unique.mk" line 26: warning: The :u modifier must merge _all_ adjacent duplicate words.
+make: "varmod-unique.mk" line 28: warning: FIXME
+make: "varmod-unique.mk" line 33: warning: The :u modifier must normalize whitespace between the words.
+make: "varmod-unique.mk" line 35: warning: FIXME
exit status 0
Index: src/usr.bin/make/unit-tests/varmod-unique.mk
diff -u src/usr.bin/make/unit-tests/varmod-unique.mk:1.2 src/usr.bin/make/unit-tests/varmod-unique.mk:1.3
--- src/usr.bin/make/unit-tests/varmod-unique.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varmod-unique.mk Mon Aug 31 17:32:13 2020
@@ -1,9 +1,40 @@
-# $NetBSD: varmod-unique.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varmod-unique.mk,v 1.3 2020/08/31 17:32:13 rillig Exp $
#
# Tests for the :u variable modifier, which discards adjacent duplicate
# words.
-# TODO: Implementation
+.if ${:U1 2 1:u} != "1 2 1"
+. error The :u modifier only merges _adjacent_ duplicate words.
+.endif
+
+.if ${:U1 2 2 3:u} != "1 2 3"
+. warning The :u modifier must merge adjacent duplicate words.
+. if ${:U1 2 2 3:u} == "1 2 3 3" # not the desired result
+. warning FIXME
+. endif
+.endif
+
+.if ${:U:u} != ""
+. error The :u modifier must do nothing with an empty word list.
+.endif
+
+.if ${:U1:u} != "1"
+. error The :u modifier must do nothing with a single-element word list.
+.endif
+
+.if ${:U1 1 1 1 1 1 1 1} != "1"
+. warning The :u modifier must merge _all_ adjacent duplicate words.
+. if ${:U1 1 1 1 1 1 1 1} == "1 1 1 1 1 1 1 1"
+. warning FIXME
+. endif
+.endif
+
+.if ${:U 1 2 1 1 } != "1 2 1"
+. warning The :u modifier must normalize whitespace between the words.
+. if ${:U 1 2 1 1 } != "1 2 1 1"
+. warning FIXME
+. endif
+.endif
all:
@:;