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 usr.bin/make: fix test for dollar an...
details: https://anonhg.NetBSD.org/src/rev/628babeb5d8e
branches: trunk
changeset: 1010181:628babeb5d8e
user: rillig <rillig%NetBSD.org@localhost>
date: Sun May 17 09:37:48 2020 +0000
description:
usr.bin/make: fix test for dollar and backslash at eol
The previous version of this test relied on the way how the shell
interprets a lonely backslash at the end of the line. The NetBSD and
FreeBSD shells print the backslash, while Bash doesn't.
While here, make the escaping a bit simpler and align the test
descriptions with the actual test data.
diffstat:
usr.bin/make/unit-tests/dollar.exp | 9 +++++----
usr.bin/make/unit-tests/dollar.mk | 23 ++++++++++++++++-------
2 files changed, 21 insertions(+), 11 deletions(-)
diffs (81 lines):
diff -r 781f96f6db97 -r 628babeb5d8e usr.bin/make/unit-tests/dollar.exp
--- a/usr.bin/make/unit-tests/dollar.exp Sun May 17 08:38:37 2020 +0000
+++ b/usr.bin/make/unit-tests/dollar.exp Sun May 17 09:37:48 2020 +0000
@@ -2,7 +2,8 @@
Printing dollar from literals and variables
To survive the parser, a dollar character must be doubled.
- 1 dollar literal => <\>
+ 1 dollar literal => <single-quote-var-value>
+ 1 dollar literal eol => <>
2 dollar literal => <$>
4 dollar literal => <$$>
Some hungry part of make eats all the dollars after a :U modifier.
@@ -33,13 +34,13 @@
The A is replaced because the $$ is reduced to a single $,
which is then resolved to the variable X with the value VAR_X.
The effective character class becomes [VAR_XY].
- C,[$XY],<&>,g => <$<A><X><Y>>
+ C,[$$XY],<&>,g => <$<A><X><Y>>
Dollar in :C pattern
For some reason, multiple dollars are folded into one.
- C,$,word, => <>
- C,$$,word, => <>
+ C,$,dollar,g => <>
+ C,$$,dollar,g => <>
Dollar in :S replacement
diff -r 781f96f6db97 -r 628babeb5d8e usr.bin/make/unit-tests/dollar.mk
--- a/usr.bin/make/unit-tests/dollar.mk Sun May 17 08:38:37 2020 +0000
+++ b/usr.bin/make/unit-tests/dollar.mk Sun May 17 09:37:48 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: dollar.mk,v 1.2 2020/05/10 13:03:40 rillig Exp $
+# $NetBSD: dollar.mk,v 1.3 2020/05/17 09:37:48 rillig Exp $
#
# Test the various places where a dollar character can appear and
# see what happens. There are lots of surprises here.
@@ -19,13 +19,22 @@
T= @testcase() { printf '%23s => <%s>\n' "$$@"; }; testcase
C= @comment() { printf '%s\n' "$$*"; }; comment
+# These variable values are not accessed.
+# The trailing dollar in the '1 dollar literal eol' test case accesses
+# the empty variable instead, which is always guaranteed to be empty.
+${:U }= space-var-value
+${:U${.newline}}= newline-var-value
+# But this one is accessed.
+${:U'}= single-quote-var-value'
+
all:
$H 'Printing dollar from literals and variables'
$C 'To survive the parser, a dollar character must be doubled.'
- $T '1 dollar literal' ''\$
- $T '2 dollar literal' ''\$$
- $T '4 dollar literal' ''\$$\$$
+ $T '1 dollar literal' '$'
+ $T '1 dollar literal eol' ''$
+ $T '2 dollar literal' '$$'
+ $T '4 dollar literal' '$$$$'
$C 'Some hungry part of make eats all the dollars after a :U modifier.'
$T '1 dollar default' ''${:U$:Q}
@@ -58,12 +67,12 @@
$C 'The A is replaced because the $$$$ is reduced to a single $$,'
$C 'which is then resolved to the variable X with the value VAR_X.'
$C 'The effective character class becomes [VAR_XY].'
- $T 'C,[$$XY],<&>,g' ''${DOLLAR_AXY:C,[$$XY],<&>,g:Q}
+ $T 'C,[$$$$XY],<&>,g' ''${DOLLAR_AXY:C,[$$XY],<&>,g:Q}
$H 'Dollar in :C pattern'
$C 'For some reason, multiple dollars are folded into one.'
- $T 'C,$$,word,' ''${DOLLAR:C,$,dollar,g:Q}
- $T 'C,$$$$,word,' ''${DOLLAR:C,$$,dollar,g:Q}
+ $T 'C,$$,dollar,g' ''${DOLLAR:C,$,dollar,g:Q}
+ $T 'C,$$$$,dollar,g' ''${DOLLAR:C,$$,dollar,g:Q}
$H 'Dollar in :S replacement'
$C 'For some reason, multiple dollars are folded into one.'
Home |
Main Index |
Thread Index |
Old Index