Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): add tests for the variable modifiers :...
details: https://anonhg.NetBSD.org/src/rev/37c39df1b2bb
branches: trunk
changeset: 1015805:37c39df1b2bb
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 01 13:55:31 2020 +0000
description:
make(1): add tests for the variable modifiers :[words] and :range
diffstat:
usr.bin/make/unit-tests/modword.exp | 2 ++
usr.bin/make/unit-tests/modword.mk | 12 ++++++++++--
usr.bin/make/unit-tests/varmod-range.exp | 10 +++++-----
usr.bin/make/unit-tests/varmod-range.mk | 5 ++++-
usr.bin/make/var.c | 6 +++---
5 files changed, 24 insertions(+), 11 deletions(-)
diffs (123 lines):
diff -r a8baa6218cbd -r 37c39df1b2bb usr.bin/make/unit-tests/modword.exp
--- a/usr.bin/make/unit-tests/modword.exp Sun Nov 01 13:28:50 2020 +0000
+++ b/usr.bin/make/unit-tests/modword.exp Sun Nov 01 13:55:31 2020 +0000
@@ -66,6 +66,7 @@
LIST:[*]:C/ /,/:[2]=""
LIST:[*]:C/ /,/:[*]:[2]=""
LIST:[*]:C/ /,/:[@]:[2]="three"
+LONGLIST:[012..0x12]="10 11 12 13 14 15 16 17 18"
make: Bad modifier `:[1.]' for LIST
LIST:[1.]="" is an error
make: Bad modifier `:[1..]' for LIST
@@ -99,6 +100,7 @@
LIST:[${LONGLIST:[21]:S/2//}]="one"
LIST:[${LIST:[#]}]="six"
LIST:[${LIST:[${HASH}]}]="six"
+LIST:[ -1.. +3]="six five four three"
LIST:S/ /,/="one two three four five six"
LIST:S/ /,/W="one,two three four five six"
LIST:S/ /,/gW="one,two,three,four,five,six"
diff -r a8baa6218cbd -r 37c39df1b2bb usr.bin/make/unit-tests/modword.mk
--- a/usr.bin/make/unit-tests/modword.mk Sun Nov 01 13:28:50 2020 +0000
+++ b/usr.bin/make/unit-tests/modword.mk Sun Nov 01 13:55:31 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: modword.mk,v 1.3 2020/10/24 08:50:17 rillig Exp $
+# $NetBSD: modword.mk,v 1.4 2020/11/01 13:55:31 rillig Exp $
#
# Test behaviour of new :[] modifier
@@ -22,7 +22,8 @@
mod-squarebrackets-hash \
mod-squarebrackets-n \
mod-squarebrackets-start-end \
- mod-squarebrackets-nested
+ mod-squarebrackets-nested \
+ mod-squarebrackets-space
mod-squarebrackets-0-star-at:
@echo 'LIST:[]="${LIST:[]}" is an error'
@@ -92,6 +93,7 @@
@echo 'LIST:[*]:C/ /,/:[2]="${LIST:[*]:C/ /,/:[2]}"'
@echo 'LIST:[*]:C/ /,/:[*]:[2]="${LIST:[*]:C/ /,/:[*]:[2]}"'
@echo 'LIST:[*]:C/ /,/:[@]:[2]="${LIST:[*]:C/ /,/:[@]:[2]}"'
+ @echo 'LONGLIST:[012..0x12]="${LONGLIST:[012..0x12]}"'
mod-squarebrackets-start-end:
@echo 'LIST:[1.]="${LIST:[1.]}" is an error'
@@ -124,6 +126,12 @@
@echo 'LIST:[$${LIST:[#]}]="${LIST:[${LIST:[#]}]}"'
@echo 'LIST:[$${LIST:[$${HASH}]}]="${LIST:[${LIST:[${HASH}]}]}"'
+mod-squarebrackets-space:
+ # As of 2020-11-01, it is possible to have spaces before the numbers
+ # but not after them. This is an unintended side-effect of using
+ # strtol for parsing the numbers.
+ @echo 'LIST:[ -1.. +3]="${LIST:[ -1.. +3]}"'
+
mod-C-W:
@echo 'LIST:C/ /,/="${LIST:C/ /,/}"'
@echo 'LIST:C/ /,/W="${LIST:C/ /,/W}"'
diff -r a8baa6218cbd -r 37c39df1b2bb usr.bin/make/unit-tests/varmod-range.exp
--- a/usr.bin/make/unit-tests/varmod-range.exp Sun Nov 01 13:28:50 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-range.exp Sun Nov 01 13:55:31 2020 +0000
@@ -1,13 +1,13 @@
make: Unknown modifier 'x'
-make: "varmod-range.mk" line 46: Malformed conditional ("${:U:range=x}Rest" != "Rest")
+make: "varmod-range.mk" line 49: Malformed conditional ("${:U:range=x}Rest" != "Rest")
make: Unknown modifier 'x'
-make: "varmod-range.mk" line 55: Malformed conditional ("${:U:range=0x0}Rest" != "Rest")
+make: "varmod-range.mk" line 58: Malformed conditional ("${:U:range=0x0}Rest" != "Rest")
make: Unknown modifier 'r'
-make: "varmod-range.mk" line 71: Malformed conditional ("${a b c:L:rang}Rest" != "Rest")
+make: "varmod-range.mk" line 74: Malformed conditional ("${a b c:L:rang}Rest" != "Rest")
make: Unknown modifier 'r'
-make: "varmod-range.mk" line 78: Malformed conditional ("${a b c:L:rango}Rest" != "Rest")
+make: "varmod-range.mk" line 81: Malformed conditional ("${a b c:L:rango}Rest" != "Rest")
make: Unknown modifier 'r'
-make: "varmod-range.mk" line 85: Malformed conditional ("${a b c:L:ranger}Rest" != "Rest")
+make: "varmod-range.mk" line 88: Malformed conditional ("${a b c:L:ranger}Rest" != "Rest")
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
diff -r a8baa6218cbd -r 37c39df1b2bb usr.bin/make/unit-tests/varmod-range.mk
--- a/usr.bin/make/unit-tests/varmod-range.mk Sun Nov 01 13:28:50 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-range.mk Sun Nov 01 13:55:31 2020 +0000
@@ -1,7 +1,10 @@
-# $NetBSD: varmod-range.mk,v 1.5 2020/11/01 13:10:22 rillig Exp $
+# $NetBSD: varmod-range.mk,v 1.6 2020/11/01 13:55:31 rillig Exp $
#
# Tests for the :range variable modifier, which generates sequences
# of integers from the given range.
+#
+# See also:
+# modword.mk
# The :range modifier generates a sequence of integers, one number per
# word of the variable expression's value.
diff -r a8baa6218cbd -r 37c39df1b2bb usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Nov 01 13:28:50 2020 +0000
+++ b/usr.bin/make/var.c Sun Nov 01 13:55:31 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.633 2020/11/01 12:34:45 rillig Exp $ */
+/* $NetBSD: var.c,v 1.634 2020/11/01 13:55:31 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.633 2020/11/01 12:34:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.634 2020/11/01 13:55:31 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -2648,7 +2648,7 @@
return AMR_BAD;
}
-/* :[#], :[1], etc. */
+/* :[#], :[1], :[-1..1], etc. */
static ApplyModifierResult
ApplyModifier_Words(const char **pp, ApplyModifiersState *st)
{
Home |
Main Index |
Thread Index |
Old Index