Module Name: src Committed By: rillig Date: Sun May 17 09:37:48 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: dollar.exp dollar.mk Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/dollar.exp \ src/usr.bin/make/unit-tests/dollar.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/unit-tests/dollar.exp diff -u src/usr.bin/make/unit-tests/dollar.exp:1.2 src/usr.bin/make/unit-tests/dollar.exp:1.3 --- src/usr.bin/make/unit-tests/dollar.exp:1.2 Sun May 10 13:03:40 2020 +++ src/usr.bin/make/unit-tests/dollar.exp Sun May 17 09:37:48 2020 @@ -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 @@ Dollar in :C character class 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 Index: src/usr.bin/make/unit-tests/dollar.mk diff -u src/usr.bin/make/unit-tests/dollar.mk:1.2 src/usr.bin/make/unit-tests/dollar.mk:1.3 --- src/usr.bin/make/unit-tests/dollar.mk:1.2 Sun May 10 13:03:40 2020 +++ src/usr.bin/make/unit-tests/dollar.mk Sun May 17 09:37:48 2020 @@ -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 @@ H= @header() { printf '\n%s\n\n' "$$*"; 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 @@ all: $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.'