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 tests/make: extend tests for modifie...



details:   https://anonhg.NetBSD.org/src/rev/ffd8ca6a880d
branches:  trunk
changeset: 368425:ffd8ca6a880d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 10 21:11:49 2022 +0000

description:
tests/make: extend tests for modifier ':H'

diffstat:

 usr.bin/make/unit-tests/varmod-head.exp |  10 -----
 usr.bin/make/unit-tests/varmod-head.mk  |  65 ++++++++++++++++++++++++++++++--
 2 files changed, 60 insertions(+), 15 deletions(-)

diffs (88 lines):

diff -r 7fdb9b50581c -r ffd8ca6a880d usr.bin/make/unit-tests/varmod-head.exp
--- a/usr.bin/make/unit-tests/varmod-head.exp   Sun Jul 10 19:49:24 2022 +0000
+++ b/usr.bin/make/unit-tests/varmod-head.exp   Sun Jul 10 21:11:49 2022 +0000
@@ -1,11 +1,1 @@
-head (dirname) of 'a/b/c' is 'a/b'
-head (dirname) of 'def' is '.'
-head (dirname) of 'a.b.c' is '.'
-head (dirname) of 'a.b/c' is 'a.b'
-head (dirname) of 'a' is '.'
-head (dirname) of 'a.a' is '.'
-head (dirname) of '.gitignore' is '.'
-head (dirname) of 'a' is '.'
-head (dirname) of 'a.a' is '.'
-head (dirname) of 'trailing/' is 'trailing'
 exit status 0
diff -r 7fdb9b50581c -r ffd8ca6a880d usr.bin/make/unit-tests/varmod-head.mk
--- a/usr.bin/make/unit-tests/varmod-head.mk    Sun Jul 10 19:49:24 2022 +0000
+++ b/usr.bin/make/unit-tests/varmod-head.mk    Sun Jul 10 21:11:49 2022 +0000
@@ -1,9 +1,64 @@
-# $NetBSD: varmod-head.mk,v 1.4 2020/12/20 22:57:40 rillig Exp $
+# $NetBSD: varmod-head.mk,v 1.5 2022/07/10 21:11:49 rillig Exp $
 #
 # Tests for the :H variable modifier, which returns the dirname of
 # each of the words in the variable value.
 
-all:
-.for path in a/b/c def a.b.c a.b/c a a.a .gitignore a a.a trailing/
-       @echo "head (dirname) of '"${path:Q}"' is '"${path:H:Q}"'"
-.endfor
+.if ${:U a/b/c :H} != "a/b"
+.  error
+.endif
+
+.if ${:U def :H} != "."
+.  error
+.endif
+
+.if ${:U a.b.c :H} != "."
+.  error
+.endif
+
+.if ${:U a.b/c :H} != "a.b"
+.  error
+.endif
+
+.if ${:U a :H} != "."
+.  error
+.endif
+
+.if ${:U a.a :H} != "."
+.  error
+.endif
+
+.if ${:U .gitignore :H} != "."
+.  error
+.endif
+
+.if ${:U trailing/ :H} != "trailing"
+.  error
+.endif
+
+.if ${:U /abs/dir/file :H} != "/abs/dir"
+.  error
+.endif
+
+.if ${:U rel/dir/file :H} != "rel/dir"
+.  error
+.endif
+
+# The head of "/" was an empty string before 2020.07.20.14.50.41, leading to
+# the output "before  after", with two spaces.  Since 2020.07.20.14.50.41, the
+# output is "before after", discarding the empty word.
+.if ${:U before/ / after/ :H} == "before after"
+# OK
+.elif ${:U before/ / after/ :H} == "before  after"
+# No '.info' to keep the file compatible with old make versions.
+_!=    echo "The modifier ':H' generates an empty word." 1>&2; echo
+.else
+.  error
+.endif
+
+# An empty list is split into a single empty word.
+# The dirname of this empty word is ".".
+.if ${:U :H} != "."
+.  error
+.endif
+
+all: .PHONY



Home | Main Index | Thread Index | Old Index