Module Name: src Committed By: rillig Date: Sun Jan 23 18:00:54 UTC 2022
Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make/unit-tests: Makefile comment.mk varmod-to-separator.exp varmod-to-separator.mk Removed Files: src/usr.bin/make/unit-tests: modts.exp modts.mk Log Message: tests/make: migrate modts to varmod-to-separator and explain To generate a diff of this commit: cvs rdiff -u -r1.1184 -r1.1185 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.299 -r1.300 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/comment.mk cvs rdiff -u -r1.6 -r0 src/usr.bin/make/unit-tests/modts.exp cvs rdiff -u -r1.8 -r0 src/usr.bin/make/unit-tests/modts.mk cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-to-separator.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-to-separator.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1184 src/distrib/sets/lists/tests/mi:1.1185 --- src/distrib/sets/lists/tests/mi:1.1184 Sun Jan 23 16:25:53 2022 +++ src/distrib/sets/lists/tests/mi Sun Jan 23 18:00:53 2022 @@ -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 Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.299 src/usr.bin/make/unit-tests/Makefile:1.300 --- src/usr.bin/make/unit-tests/Makefile:1.299 Sun Jan 23 16:25:54 2022 +++ src/usr.bin/make/unit-tests/Makefile Sun Jan 23 18:00:53 2022 @@ -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+= meta-cmd-cmp TESTS+= moderrs TESTS+= modmatch TESTS+= modmisc -TESTS+= modts .if ${.MAKE.UID} > 0 TESTS+= objdir-writable .endif Index: src/usr.bin/make/unit-tests/comment.mk diff -u src/usr.bin/make/unit-tests/comment.mk:1.3 src/usr.bin/make/unit-tests/comment.mk:1.4 --- src/usr.bin/make/unit-tests/comment.mk:1.3 Sun Nov 15 14:07:53 2020 +++ src/usr.bin/make/unit-tests/comment.mk Sun Jan 23 18:00:53 2022 @@ -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 @@ on and on. # 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. Index: src/usr.bin/make/unit-tests/varmod-to-separator.exp diff -u src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.8 src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.9 --- src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.8 Thu Dec 9 20:27:01 2021 +++ src/usr.bin/make/unit-tests/varmod-to-separator.exp Sun Jan 23 18:00:53 2022 @@ -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 Index: src/usr.bin/make/unit-tests/varmod-to-separator.mk diff -u src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.7 src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.8 --- src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.7 Sun Nov 15 20:20:58 2020 +++ src/usr.bin/make/unit-tests/varmod-to-separator.mk Sun Jan 23 18:00:53 2022 @@ -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 @@ WORDS= one two three four five six . 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 @@ WORDS= one two three four five six # 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 @@ WORDS= one two three four five six # for ':ts\90' ('Z' in decimal ASCII, undefined in octal)? # TODO: :ts\x1F600 - -all: