Module Name: src Committed By: rillig Date: Sat Jul 31 20:55:46 UTC 2021
Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make/unit-tests: Makefile varmod-order-numeric.exp varmod-order-numeric.mk varmod-order.exp varmod-order.mk Added Files: src/usr.bin/make/unit-tests: varmod-order-string.exp varmod-order-string.mk Log Message: tests/make: split tests for the variable modifier ':O' The tests for parse errors are now in varmod-order, which lets the other tests focus on the desired behavior of the modifiers. To generate a diff of this commit: cvs rdiff -u -r1.1097 -r1.1098 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.281 -r1.282 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-order-numeric.exp \ src/usr.bin/make/unit-tests/varmod-order-numeric.mk \ src/usr.bin/make/unit-tests/varmod-order.exp cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-order-string.exp \ src/usr.bin/make/unit-tests/varmod-order-string.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-order.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.1097 src/distrib/sets/lists/tests/mi:1.1098 --- src/distrib/sets/lists/tests/mi:1.1097 Fri Jul 30 21:29:00 2021 +++ src/distrib/sets/lists/tests/mi Sat Jul 31 20:55:45 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1097 2021/07/30 21:29:00 rillig Exp $ +# $NetBSD: mi,v 1.1098 2021/07/31 20:55:45 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5815,6 +5815,8 @@ ./usr/tests/usr.bin/make/unit-tests/varmod-order-reverse.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varmod-order-shuffle.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varmod-order-shuffle.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/varmod-order-string.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/varmod-order-string.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varmod-order.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varmod-order.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varmod-path.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.281 src/usr.bin/make/unit-tests/Makefile:1.282 --- src/usr.bin/make/unit-tests/Makefile:1.281 Fri Jul 30 19:55:22 2021 +++ src/usr.bin/make/unit-tests/Makefile Sat Jul 31 20:55:46 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.281 2021/07/30 19:55:22 sjg Exp $ +# $NetBSD: Makefile,v 1.282 2021/07/31 20:55:46 rillig Exp $ # # Unit tests for make(1) # @@ -358,6 +358,7 @@ TESTS+= varmod-order TESTS+= varmod-order-numeric TESTS+= varmod-order-reverse TESTS+= varmod-order-shuffle +TESTS+= varmod-order-string TESTS+= varmod-path TESTS+= varmod-quote TESTS+= varmod-quote-dollar Index: src/usr.bin/make/unit-tests/varmod-order-numeric.exp diff -u src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.3 src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.4 --- src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.3 Fri Jul 30 23:28:04 2021 +++ src/usr.bin/make/unit-tests/varmod-order-numeric.exp Sat Jul 31 20:55:46 2021 @@ -1,20 +1 @@ -make: Bad modifier ":Oxn" for variable "NUMBERS" -make: "varmod-order-numeric.mk" line 32: Malformed conditional (${NUMBERS:Oxn}) -make: Bad modifier ":On_typo" for variable "NUMBERS" -make: "varmod-order-numeric.mk" line 42: Malformed conditional (${NUMBERS:On_typo}) -make: Bad modifier ":Onr_typo" for variable "NUMBERS" -make: "varmod-order-numeric.mk" line 51: Malformed conditional (${NUMBERS:Onr_typo}) -make: Bad modifier ":Orn_typo" for variable "NUMBERS" -make: "varmod-order-numeric.mk" line 60: Malformed conditional (${NUMBERS:Orn_typo}) -make: Bad modifier ":Onn" for variable "NUMBERS" -make: "varmod-order-numeric.mk" line 71: Malformed conditional (${NUMBERS:Onn}) -make: Bad modifier ":Onrr" for variable "NUMBERS" -make: "varmod-order-numeric.mk" line 80: Malformed conditional (${NUMBERS:Onrr}) -make: Bad modifier ":Orrn" for variable "NUMBERS" -make: "varmod-order-numeric.mk" line 89: Malformed conditional (${NUMBERS:Orrn}) -make: Unclosed variable expression, expecting '}' for modifier "O" of variable "NUMBERS" with value "-2G -3m -42 1 1M 1k 3 42 5 5K 7" -make: Unclosed variable expression, expecting '}' for modifier "On" of variable "NUMBERS" with value "-2G -3m -42 1 3 5 7 42 1k 5K 1M" -make: Unclosed variable expression, expecting '}' for modifier "Onr" of variable "NUMBERS" with value "1M 5K 1k 42 7 5 3 1 -42 -3m -2G" -make: Fatal errors encountered -- cannot continue -make: stopped in unit-tests -exit status 1 +exit status 0 Index: src/usr.bin/make/unit-tests/varmod-order-numeric.mk diff -u src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.3 src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.4 --- src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.3 Fri Jul 30 23:28:04 2021 +++ src/usr.bin/make/unit-tests/varmod-order-numeric.mk Sat Jul 31 20:55:46 2021 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-order-numeric.mk,v 1.3 2021/07/30 23:28:04 rillig Exp $ +# $NetBSD: varmod-order-numeric.mk,v 1.4 2021/07/31 20:55:46 rillig Exp $ # # Tests for the :On variable modifier, which returns the words, sorted in # ascending numeric order. @@ -24,77 +24,17 @@ NUMBERS= 3 5 7 1 42 -42 5K -3m 1M 1k -2G . error ${NUMBERS:Onr} .endif -# Shuffling numerically doesn't make sense, so don't allow 'x' and 'n' to be -# combined. -# -# expect-text: Bad modifier ":Oxn" for variable "NUMBERS" -# expect+1: Malformed conditional (${NUMBERS:Oxn}) -.if ${NUMBERS:Oxn} -. error -.else -. error -.endif - -# Extra characters after ':On' are detected and diagnosed. -# TODO: Add line number information to the "Bad modifier" diagnostic. -# -# expect-text: Bad modifier ":On_typo" for variable "NUMBERS" -.if ${NUMBERS:On_typo} -. error -.else -. error -.endif - -# Extra characters after ':Onr' are detected and diagnosed. -# -# expect-text: Bad modifier ":Onr_typo" for variable "NUMBERS" -.if ${NUMBERS:Onr_typo} -. error -.else -. error -.endif - -# Extra characters after ':Orn' are detected and diagnosed. -# -# expect+1: Bad modifier ":Orn_typo" for variable "NUMBERS" -.if ${NUMBERS:Orn_typo} -. error -.else -. error +# If there are several numbers that have the same integer value, they are +# returned in unspecified order. +SAME_VALUE:= ${:U 79 80 0x0050 81 :On} +.if ${SAME_VALUE} != "79 80 0x0050 81" && ${SAME_VALUE} != "79 0x0050 80 81" +. error ${SAME_VALUE} .endif -# Repeating the 'n' is not supported. In the typical use cases, the sorting -# criteria are fixed, not computed, therefore allowing this redundancy does -# not make sense. -# -# expect-text: Bad modifier ":Onn" for variable "NUMBERS" -.if ${NUMBERS:Onn} -. error -.else -. error -.endif - -# Repeating the 'r' is not supported as well, for the same reasons as above. -# -# expect-text: Bad modifier ":Onrr" for variable "NUMBERS" -.if ${NUMBERS:Onrr} -. error -.else -. error +# Hexadecimal and octal numbers are supported as well. +OCTAL= 0 010 0x7 9 +.if ${OCTAL:On} != "0 0x7 010 9" +. error ${OCTAL:On} .endif -# Repeating the 'r' is not supported as well, for the same reasons as above. -# -# expect-text: Bad modifier ":Orrn" for variable "NUMBERS" -.if ${NUMBERS:Orrn} -. error -.else -. error -.endif - -# Missing closing brace, to cover the error handling code. -_:= ${NUMBERS:O -_:= ${NUMBERS:On -_:= ${NUMBERS:Onr - all: Index: src/usr.bin/make/unit-tests/varmod-order.exp diff -u src/usr.bin/make/unit-tests/varmod-order.exp:1.3 src/usr.bin/make/unit-tests/varmod-order.exp:1.4 --- src/usr.bin/make/unit-tests/varmod-order.exp:1.3 Tue Feb 23 16:07:14 2021 +++ src/usr.bin/make/unit-tests/varmod-order.exp Sat Jul 31 20:55:46 2021 @@ -2,6 +2,23 @@ make: Bad modifier ":OX" for variable "N make: "varmod-order.mk" line 13: Undefined variable "${NUMBERS:OX" make: Bad modifier ":OxXX" for variable "NUMBERS" make: "varmod-order.mk" line 16: Undefined variable "${NUMBERS:Ox" +make: Unclosed variable expression, expecting '}' for modifier "O" of variable "NUMBERS" with value "eight five four nine one seven six ten three two" +make: Unclosed variable expression, expecting '}' for modifier "On" of variable "NUMBERS" with value "ten two three four five six seven eight nine one" +make: Unclosed variable expression, expecting '}' for modifier "Onr" of variable "NUMBERS" with value "ten two three four five six seven eight nine one" +make: Bad modifier ":Oxn" for variable "NUMBERS" +make: "varmod-order.mk" line 28: Malformed conditional (${NUMBERS:Oxn}) +make: Bad modifier ":On_typo" for variable "NUMBERS" +make: "varmod-order.mk" line 38: Malformed conditional (${NUMBERS:On_typo}) +make: Bad modifier ":Onr_typo" for variable "NUMBERS" +make: "varmod-order.mk" line 47: Malformed conditional (${NUMBERS:Onr_typo}) +make: Bad modifier ":Orn_typo" for variable "NUMBERS" +make: "varmod-order.mk" line 56: Malformed conditional (${NUMBERS:Orn_typo}) +make: Bad modifier ":Onn" for variable "NUMBERS" +make: "varmod-order.mk" line 67: Malformed conditional (${NUMBERS:Onn}) +make: Bad modifier ":Onrr" for variable "NUMBERS" +make: "varmod-order.mk" line 76: Malformed conditional (${NUMBERS:Onrr}) +make: Bad modifier ":Orrn" for variable "NUMBERS" +make: "varmod-order.mk" line 85: Malformed conditional (${NUMBERS:Orrn}) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varmod-order.mk diff -u src/usr.bin/make/unit-tests/varmod-order.mk:1.5 src/usr.bin/make/unit-tests/varmod-order.mk:1.6 --- src/usr.bin/make/unit-tests/varmod-order.mk:1.5 Sat Oct 24 08:46:08 2020 +++ src/usr.bin/make/unit-tests/varmod-order.mk Sat Jul 31 20:55:46 2021 @@ -1,7 +1,7 @@ -# $NetBSD: varmod-order.mk,v 1.5 2020/10/24 08:46:08 rillig Exp $ +# $NetBSD: varmod-order.mk,v 1.6 2021/07/31 20:55:46 rillig Exp $ # -# Tests for the :O variable modifier, which returns the words, sorted in -# ascending order. +# Tests for the :O variable modifier and its variants, which either sort the +# words of the value or shuffle them. NUMBERS= one two three four five six seven eight nine ten @@ -15,5 +15,77 @@ _:= ${NUMBERS:OX} # Unknown modifier "OxXX" _:= ${NUMBERS:OxXX} +# Missing closing brace, to cover the error handling code. +_:= ${NUMBERS:O +_:= ${NUMBERS:On +_:= ${NUMBERS:Onr + +# Shuffling numerically doesn't make sense, so don't allow 'x' and 'n' to be +# combined. +# +# expect-text: Bad modifier ":Oxn" for variable "NUMBERS" +# expect+1: Malformed conditional (${NUMBERS:Oxn}) +.if ${NUMBERS:Oxn} +. error +.else +. error +.endif + +# Extra characters after ':On' are detected and diagnosed. +# TODO: Add line number information to the "Bad modifier" diagnostic. +# +# expect-text: Bad modifier ":On_typo" for variable "NUMBERS" +.if ${NUMBERS:On_typo} +. error +.else +. error +.endif + +# Extra characters after ':Onr' are detected and diagnosed. +# +# expect-text: Bad modifier ":Onr_typo" for variable "NUMBERS" +.if ${NUMBERS:Onr_typo} +. error +.else +. error +.endif + +# Extra characters after ':Orn' are detected and diagnosed. +# +# expect+1: Bad modifier ":Orn_typo" for variable "NUMBERS" +.if ${NUMBERS:Orn_typo} +. error +.else +. error +.endif + +# Repeating the 'n' is not supported. In the typical use cases, the sorting +# criteria are fixed, not computed, therefore allowing this redundancy does +# not make sense. +# +# expect-text: Bad modifier ":Onn" for variable "NUMBERS" +.if ${NUMBERS:Onn} +. error +.else +. error +.endif + +# Repeating the 'r' is not supported as well, for the same reasons as above. +# +# expect-text: Bad modifier ":Onrr" for variable "NUMBERS" +.if ${NUMBERS:Onrr} +. error +.else +. error +.endif + +# Repeating the 'r' is not supported as well, for the same reasons as above. +# +# expect-text: Bad modifier ":Orrn" for variable "NUMBERS" +.if ${NUMBERS:Orrn} +. error +.else +. error +.endif + all: - @:; Added files: Index: src/usr.bin/make/unit-tests/varmod-order-string.exp diff -u /dev/null src/usr.bin/make/unit-tests/varmod-order-string.exp:1.1 --- /dev/null Sat Jul 31 20:55:46 2021 +++ src/usr.bin/make/unit-tests/varmod-order-string.exp Sat Jul 31 20:55:46 2021 @@ -0,0 +1 @@ +exit status 0 Index: src/usr.bin/make/unit-tests/varmod-order-string.mk diff -u /dev/null src/usr.bin/make/unit-tests/varmod-order-string.mk:1.1 --- /dev/null Sat Jul 31 20:55:46 2021 +++ src/usr.bin/make/unit-tests/varmod-order-string.mk Sat Jul 31 20:55:46 2021 @@ -0,0 +1,28 @@ +# $NetBSD: varmod-order-string.mk,v 1.1 2021/07/31 20:55:46 rillig Exp $ +# +# Tests for the :O variable modifier, which returns the words, sorted in +# ascending order. + +# Simple words are sorted lexicographically. +WORDS= one two three four five six seven eight nine ten +.if ${WORDS:O} != "eight five four nine one seven six ten three two" +. error ${WORDS:O} +.endif + +# Double quotes and single quotes delimit words, while backticks are just +# regular characters. Therefore '`in' is a separate word from 'backticks`', +# and the additional spaces between them are removed. +QUOTED_WORDS= none "double quoted" 'single quoted' `in backticks` +.if ${QUOTED_WORDS:O} != "\"double quoted\" 'single quoted' `in backticks` none" +. error ${QUOTED_WORDS:O} +.endif + +# Numbers are sorted lexicographically as well. +# To sort the words numerically, use ':On' instead; since var.c 1.939 from +# 2021-07-30. +NUMBERS= -100g -50m -7k -50 -13 0 000 13 50 5k1 7k 50m 100G +.if ${NUMBERS:O} != "-100g -13 -50 -50m -7k 0 000 100G 13 50 50m 5k1 7k" +. error ${NUMBERS:O} +.endif + +all: