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: migrate modts to varmod-...



details:   https://anonhg.NetBSD.org/src/rev/485c6756b93c
branches:  trunk
changeset: 359803:485c6756b93c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 23 18:00:53 2022 +0000

description:
tests/make: migrate modts to varmod-to-separator and explain

diffstat:

 distrib/sets/lists/tests/mi                     |   6 +-
 usr.bin/make/unit-tests/Makefile                |   3 +-
 usr.bin/make/unit-tests/comment.mk              |   6 +-
 usr.bin/make/unit-tests/modts.exp               |  14 -----
 usr.bin/make/unit-tests/modts.mk                |  47 -----------------
 usr.bin/make/unit-tests/varmod-to-separator.exp |  22 ++++---
 usr.bin/make/unit-tests/varmod-to-separator.mk  |  66 ++++++++++++++++++++++--
 7 files changed, 80 insertions(+), 84 deletions(-)

diffs (252 lines):

diff -r 9e5dc2167347 -r 485c6756b93c distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Jan 23 16:48:37 2022 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Jan 23 18:00:53 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1184 2022/01/23 16:25:53 rillig Exp $
+# $NetBSD: mi,v 1.1185 2022/01/23 18:00:53 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5721,8 +5721,8 @@
 ./usr/tests/usr.bin/make/unit-tests/modmisc.mk                                 tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/modorder.exp                               tests-obsolete          obsolete
 ./usr/tests/usr.bin/make/unit-tests/modorder.mk                                        tests-obsolete          obsolete
-./usr/tests/usr.bin/make/unit-tests/modts.exp                                  tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/modts.mk                                   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/modts.exp                                  tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/make/unit-tests/modts.mk                                   tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/make/unit-tests/modword.exp                                        tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/make/unit-tests/modword.mk                                 tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/make/unit-tests/objdir-writable.exp                                tests-usr.bin-tests     compattestfile,atf
diff -r 9e5dc2167347 -r 485c6756b93c usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sun Jan 23 16:48:37 2022 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sun Jan 23 18:00:53 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.299 2022/01/23 16:25:54 rillig Exp $
+# $NetBSD: Makefile,v 1.300 2022/01/23 18:00:53 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -218,7 +218,6 @@
 TESTS+=                moderrs
 TESTS+=                modmatch
 TESTS+=                modmisc
-TESTS+=                modts
 .if ${.MAKE.UID} > 0
 TESTS+=                objdir-writable
 .endif
diff -r 9e5dc2167347 -r 485c6756b93c usr.bin/make/unit-tests/comment.mk
--- a/usr.bin/make/unit-tests/comment.mk        Sun Jan 23 16:48:37 2022 +0000
+++ b/usr.bin/make/unit-tests/comment.mk        Sun Jan 23 18:00:53 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: comment.mk,v 1.3 2020/11/15 14:07:53 rillig Exp $
+# $NetBSD: comment.mk,v 1.4 2022/01/23 18:00:53 rillig Exp $
 #
 # Demonstrate how comments are written in makefiles.
 
@@ -15,7 +15,9 @@
  # Comments can be indented with spaces, but that is rather unusual.
 
        # Comments can be indented with a tab.
-       # These are not shell commands, they are just makefile comments.
+       # Since parse.c 1.127 from 2007-01-01, these are not shell commands,
+       # they are just makefile comments.  Before that commit, these comments
+       # triggered the error message "Unassociated shell command".
 
 .if 1                  # There can be comments after conditions.
 .endif                 # And after the closing directive.
diff -r 9e5dc2167347 -r 485c6756b93c usr.bin/make/unit-tests/modts.exp
--- a/usr.bin/make/unit-tests/modts.exp Sun Jan 23 16:48:37 2022 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-make: Bad modifier ":tx" for variable "LIST"
-LIST:tx="}"
-make: Bad modifier ":ts\X" for variable "LIST"
-LIST:ts/x:tu="\X:tu}"
-FU_mod-ts="a/b/cool"
-FU_mod-ts:ts:T="cool" == cool?
-B.${AAA:ts}="Baaa" == Baaa?
-:ts :S => aaxBbxaaxbbxaaxbb
-:ts :S space    => axa a axc
-:ts :S space :M => axaxaxaxc
-:ts :S       => axa a axc
-:ts :S :@    => axa a axc
-:ts :S :@ :M => axaxaxaxc
-exit status 0
diff -r 9e5dc2167347 -r 485c6756b93c usr.bin/make/unit-tests/modts.mk
--- a/usr.bin/make/unit-tests/modts.mk  Sun Jan 23 16:48:37 2022 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# $NetBSD: modts.mk,v 1.8 2020/11/03 18:42:33 rillig Exp $
-
-LIST=  one two three four five six
-
-FU_mod-ts=     a / b / cool
-
-AAA=   a a a
-B.aaa= Baaa
-
-all:   mod-ts mod-ts-space
-
-# Use print or printf iff they are builtin.
-# XXX note that this causes problems, when make decides
-# there is no need to use a shell, so avoid where possible.
-.if ${type print 2> /dev/null || echo:L:sh:Mbuiltin} != ""
-PRINT= print -r --
-.elif ${type printf 2> /dev/null || echo:L:sh:Mbuiltin} != ""
-PRINT= printf '%s\n'
-.else
-PRINT= echo
-.endif
-
-mod-ts:
-       @${PRINT} 'LIST:tx="${LIST:tx}"'
-       @${PRINT} 'LIST:ts/x:tu="${LIST:ts\X:tu}"'
-       @${PRINT} 'FU_$@="${FU_${@:ts}:ts}"'
-       @${PRINT} 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
-       @${PRINT} 'B.$${AAA:ts}="${B.${AAA:ts}}" == Baaa?'
-
-mod-ts-space:
-       # After the :ts modifier, the whole string is interpreted as a single
-       # word since all spaces have been replaced with x.
-       @${PRINT} ':ts :S => '${aa bb aa bb aa bb:L:tsx:S,b,B,:Q}
-
-       # The :ts modifier also applies to word separators that are added
-       # afterwards.
-       @${PRINT} ':ts :S space    => '${a ababa c:L:tsx:S,b, ,g:Q}
-       @${PRINT} ':ts :S space :M => '${a ababa c:L:tsx:S,b, ,g:M*:Q}
-
-       # Not all modifiers behave this way though.  Some of them always use
-       # a space as word separator instead of the :ts separator.
-       # This seems like an oversight during implementation.
-       @${PRINT} ':ts :S       => '${a ababa c:L:tsx:S,b, ,g:Q}
-       @${PRINT} ':ts :S :@    => '${a ababa c:L:tsx:S,b, ,g:@v@${v}@:Q}
-
-       # A final :M* modifier applies the :ts separator again, though.
-       @${PRINT} ':ts :S :@ :M => '${a ababa c:L:tsx:S,b, ,g:@v@${v}@:M*:Q}
diff -r 9e5dc2167347 -r 485c6756b93c usr.bin/make/unit-tests/varmod-to-separator.exp
--- a/usr.bin/make/unit-tests/varmod-to-separator.exp   Sun Jan 23 16:48:37 2022 +0000
+++ b/usr.bin/make/unit-tests/varmod-to-separator.exp   Sun Jan 23 18:00:53 2022 +0000
@@ -1,19 +1,21 @@
-make: "varmod-to-separator.mk" line 107: Invalid character number at "400:tu}"
-make: "varmod-to-separator.mk" line 107: Malformed conditional (${WORDS:[1..3]:ts\400:tu})
-make: "varmod-to-separator.mk" line 121: Invalid character number at "100:tu}"
-make: "varmod-to-separator.mk" line 121: Malformed conditional (${WORDS:[1..3]:ts\x100:tu})
+make: "varmod-to-separator.mk" line 153: Invalid character number at "400:tu}"
+make: "varmod-to-separator.mk" line 153: Malformed conditional (${WORDS:[1..3]:ts\400:tu})
+make: "varmod-to-separator.mk" line 167: Invalid character number at "100:tu}"
+make: "varmod-to-separator.mk" line 167: Malformed conditional (${WORDS:[1..3]:ts\x100:tu})
 make: Bad modifier ":ts\-300" for variable "WORDS"
-make: "varmod-to-separator.mk" line 128: Malformed conditional (${WORDS:[1..3]:ts\-300:tu})
+make: "varmod-to-separator.mk" line 174: Malformed conditional (${WORDS:[1..3]:ts\-300:tu})
 make: Bad modifier ":ts\8" for variable "1 2 3"
-make: "varmod-to-separator.mk" line 136: Malformed conditional (${1 2 3:L:ts\8:tu})
+make: "varmod-to-separator.mk" line 182: Malformed conditional (${1 2 3:L:ts\8:tu})
 make: Bad modifier ":ts\100L" for variable "1 2 3"
-make: "varmod-to-separator.mk" line 143: Malformed conditional (${1 2 3:L:ts\100L})
+make: "varmod-to-separator.mk" line 189: Malformed conditional (${1 2 3:L:ts\100L})
 make: Bad modifier ":ts\x40g" for variable "1 2 3"
-make: "varmod-to-separator.mk" line 150: Malformed conditional (${1 2 3:L:ts\x40g})
+make: "varmod-to-separator.mk" line 196: Malformed conditional (${1 2 3:L:ts\x40g})
 make: Bad modifier ":tx" for variable "WORDS"
-make: "varmod-to-separator.mk" line 158: Malformed conditional (${WORDS:tx} != "anything")
+make: "varmod-to-separator.mk" line 205: Malformed conditional (${WORDS:tx})
+make: Bad modifier ":ts\X" for variable "WORDS"
+make: "varmod-to-separator.mk" line 213: Malformed conditional (${WORDS:ts\X})
 make: Bad modifier ":t\X" for variable "WORDS"
-make: "varmod-to-separator.mk" line 165: Malformed conditional (${WORDS:t\X} != "anything")
+make: "varmod-to-separator.mk" line 221: Malformed conditional (${WORDS:t\X} != "anything")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r 9e5dc2167347 -r 485c6756b93c usr.bin/make/unit-tests/varmod-to-separator.mk
--- a/usr.bin/make/unit-tests/varmod-to-separator.mk    Sun Jan 23 16:48:37 2022 +0000
+++ b/usr.bin/make/unit-tests/varmod-to-separator.mk    Sun Jan 23 18:00:53 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-to-separator.mk,v 1.7 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: varmod-to-separator.mk,v 1.8 2022/01/23 18:00:53 rillig Exp $
 #
 # Tests for the :ts variable modifier, which joins the words of the variable
 # using an arbitrary character as word separator.
@@ -80,6 +80,52 @@
 .  warning The :ts modifier followed by an :S modifier does not work.
 .endif
 
+# After the modifier ':ts/', the expression value is a single word since all
+# spaces have been replaced with '/'.  This single word does not start with
+# 'two', which makes the modifier ':S' a no-op.
+.if ${WORDS:ts/:S/^two/2/} != "one/two/three/four/five/six"
+.  error
+.endif
+
+# After the :ts modifier, the whole string is interpreted as a single
+# word since all spaces have been replaced with x.  Because of this single
+# word, only the first 'b' is replaced with 'B'.
+.if ${aa bb aa bb aa bb:L:tsx:S,b,B,} != "aaxBbxaaxbbxaaxbb"
+.  error
+.endif
+
+# The :ts modifier also applies to word separators that are added
+# afterwards.  First, the modifier ':tsx' joins the 3 words, then the modifier
+# ':S' replaces the 2 'b's with spaces.  These spaces are part of the word,
+# so when the words are joined at the end of the modifier ':S', there is only
+# a single word, and the custom separator from the modifier ':tsx' has no
+# effect.
+.if ${a ababa c:L:tsx:S,b, ,g} != "axa a axc"
+.  error
+.endif
+
+# Adding the modifier ':M*' at the end of the above chain splits the
+# expression value and then joins it again.  At this point of splitting, the
+# newly added spaces are treated as word separators, resulting in 3 words.
+# When these 3 words are joined, the separator from the modifier ':tsx' is
+# used.
+.if ${a ababa c:L:tsx:S,b, ,g:M*} != "axaxaxaxc"
+.  error
+.endif
+
+# Not all modifiers use the separator from the previous modifier ':ts' though.
+# The modifier ':@' always uses a space as word separator instead.  This has
+# probably been an oversight during implementation.  For consistency, the
+# result should rather be "axaxaxaxc", as in the previous example.
+.if ${a ababa c:L:tsx:S,b, ,g:@v@$v@} != "axa a axc"
+.  error
+.endif
+
+# Adding a final :M* modifier applies the :ts separator again, though.
+.if ${a ababa c:L:tsx:S,b, ,g:@v@${v}@:M*} != "axaxaxaxc"
+.  error
+.endif
+
 # The separator can be \n, which is a newline.
 .if ${WORDS:[1..3]:ts\n} != "one${.newline}two${.newline}three"
 .  warning The separator \n does not produce a newline.
@@ -155,9 +201,19 @@
 
 
 # In the :t modifier, the :t must be followed by any of A, l, s, u.
-.if ${WORDS:tx} != "anything"
-.  info This line is not reached because of the malformed condition.
-.  info If this line were reached, it would be visible in the -dcpv log.
+# expect: Bad modifier ":tx" for variable "WORDS"
+.if ${WORDS:tx}
+.  error
+.else
+.  error
+.endif
+
+# The word separator must be can only be a single character.
+# expect: Bad modifier ":ts\X" for variable "WORDS"
+.if ${WORDS:ts\X}
+.  error
+.else
+.  error
 .endif
 
 # After the backslash, only n, t, an octal number, or x and a hexadecimal
@@ -171,5 +227,3 @@
 # for ':ts\90' ('Z' in decimal ASCII, undefined in octal)?
 
 # TODO: :ts\x1F600
-
-all:



Home | Main Index | Thread Index | Old Index