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: split tests for the vari...
details: https://anonhg.NetBSD.org/src/rev/ba1abbcf0806
branches: trunk
changeset: 984935:ba1abbcf0806
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jul 31 20:55:45 2021 +0000
description:
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.
diffstat:
distrib/sets/lists/tests/mi | 4 +-
usr.bin/make/unit-tests/Makefile | 3 +-
usr.bin/make/unit-tests/varmod-order-numeric.exp | 21 +------
usr.bin/make/unit-tests/varmod-order-numeric.mk | 80 +++---------------------
usr.bin/make/unit-tests/varmod-order-string.exp | 1 +
usr.bin/make/unit-tests/varmod-order-string.mk | 28 ++++++++
usr.bin/make/unit-tests/varmod-order.exp | 17 +++++
usr.bin/make/unit-tests/varmod-order.mk | 80 ++++++++++++++++++++++-
8 files changed, 138 insertions(+), 96 deletions(-)
diffs (truncated from 313 to 300 lines):
diff -r 4718aa6e2383 -r ba1abbcf0806 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sat Jul 31 20:51:32 2021 +0000
+++ b/distrib/sets/lists/tests/mi Sat Jul 31 20:55:45 2021 +0000
@@ -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
diff -r 4718aa6e2383 -r ba1abbcf0806 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Sat Jul 31 20:51:32 2021 +0000
+++ b/usr.bin/make/unit-tests/Makefile Sat Jul 31 20:55:45 2021 +0000
@@ -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-numeric
TESTS+= varmod-order-reverse
TESTS+= varmod-order-shuffle
+TESTS+= varmod-order-string
TESTS+= varmod-path
TESTS+= varmod-quote
TESTS+= varmod-quote-dollar
diff -r 4718aa6e2383 -r ba1abbcf0806 usr.bin/make/unit-tests/varmod-order-numeric.exp
--- a/usr.bin/make/unit-tests/varmod-order-numeric.exp Sat Jul 31 20:51:32 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-order-numeric.exp Sat Jul 31 20:55:45 2021 +0000
@@ -1,20 +1,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
diff -r 4718aa6e2383 -r ba1abbcf0806 usr.bin/make/unit-tests/varmod-order-numeric.mk
--- a/usr.bin/make/unit-tests/varmod-order-numeric.mk Sat Jul 31 20:51:32 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-order-numeric.mk Sat Jul 31 20:55:45 2021 +0000
@@ -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 @@
. 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
+# 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
-# 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
+# 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 ":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
-
-# Missing closing brace, to cover the error handling code.
-_:= ${NUMBERS:O
-_:= ${NUMBERS:On
-_:= ${NUMBERS:Onr
-
all:
diff -r 4718aa6e2383 -r ba1abbcf0806 usr.bin/make/unit-tests/varmod-order-string.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/varmod-order-string.exp Sat Jul 31 20:55:45 2021 +0000
@@ -0,0 +1,1 @@
+exit status 0
diff -r 4718aa6e2383 -r ba1abbcf0806 usr.bin/make/unit-tests/varmod-order-string.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/varmod-order-string.mk Sat Jul 31 20:55:45 2021 +0000
@@ -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:
diff -r 4718aa6e2383 -r ba1abbcf0806 usr.bin/make/unit-tests/varmod-order.exp
--- a/usr.bin/make/unit-tests/varmod-order.exp Sat Jul 31 20:51:32 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-order.exp Sat Jul 31 20:55:45 2021 +0000
@@ -2,6 +2,23 @@
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
diff -r 4718aa6e2383 -r ba1abbcf0806 usr.bin/make/unit-tests/varmod-order.mk
--- a/usr.bin/make/unit-tests/varmod-order.mk Sat Jul 31 20:51:32 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-order.mk Sat Jul 31 20:55:45 2021 +0000
@@ -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 @@
# 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
Home |
Main Index |
Thread Index |
Old Index