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 test for the currently ...
details: https://anonhg.NetBSD.org/src/rev/3a0558573861
branches: trunk
changeset: 1013579:3a0558573861
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Aug 31 17:32:13 2020 +0000
description:
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.
diffstat:
usr.bin/make/unit-tests/varmod-unique.exp | 6 +++++
usr.bin/make/unit-tests/varmod-unique.mk | 35 +++++++++++++++++++++++++++++-
2 files changed, 39 insertions(+), 2 deletions(-)
diffs (57 lines):
diff -r 443136136815 -r 3a0558573861 usr.bin/make/unit-tests/varmod-unique.exp
--- a/usr.bin/make/unit-tests/varmod-unique.exp Mon Aug 31 17:25:29 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-unique.exp Mon Aug 31 17:32:13 2020 +0000
@@ -1,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
diff -r 443136136815 -r 3a0558573861 usr.bin/make/unit-tests/varmod-unique.mk
--- a/usr.bin/make/unit-tests/varmod-unique.mk Mon Aug 31 17:25:29 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-unique.mk Mon Aug 31 17:32:13 2020 +0000
@@ -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:
@:;
Home |
Main Index |
Thread Index |
Old Index