Module Name:    src
Committed By:   kre
Date:           Mon May 29 22:27:47 UTC 2017

Modified Files:
        src/tests/bin/sh: t_expand.sh

Log Message:
Add a new test case wrap_strip based upon strip (ie: cut&paste.. to start)
but with \ newline line continuations inserted at strange places.

For the shell as it is today, since strip passes, wrap_strip should
automaticallty pass as well (and does), as the \ newline combination
is simply removed, producing identical input to that of strip.

However, for accurate line counting ($LINENO: coming soon) newlines (no
matter the context) cannot simply "go away" - we have to know where they
occur(ed) (perhaps long after the text was read)  so we know what line
number we are actually processing.   This new test case is (perhaps just
part) of future-proofing that the modified code does not break anything.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/bin/sh/t_expand.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/bin/sh/t_expand.sh
diff -u src/tests/bin/sh/t_expand.sh:1.13 src/tests/bin/sh/t_expand.sh:1.14
--- src/tests/bin/sh/t_expand.sh:1.13	Mon May 15 19:53:40 2017
+++ src/tests/bin/sh/t_expand.sh	Mon May 29 22:27:47 2017
@@ -1,4 +1,4 @@
-# $NetBSD: t_expand.sh,v 1.13 2017/05/15 19:53:40 kre Exp $
+# $NetBSD: t_expand.sh,v 1.14 2017/05/29 22:27:47 kre Exp $
 #
 # Copyright (c) 2007, 2009 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -156,6 +156,50 @@ strip_body() {
 	done
 }
 
+atf_test_case wrap_strip
+wrap_strip_head() {
+	atf_set "descr" "Checks that the %% operator works and strips" \
+	                "the contents of a variable from the given point" \
+			'to the end, and that \ \n sequences do not break it'
+}
+wrap_strip_body() {
+	line='#define bindir "/usr/bin" /* comment */'
+	stripped='#define bindir "/usr/bin" '
+
+	for exp in 				\
+		'${line\
+%%/\**}'					\
+		'${line%%"/\
+*"*}'						\
+		'${line%%'"'"'/*'"'"'\
+*}'						\
+		'"${li\
+ne%%/\**}"'					\
+		'"${line%%"\
+/*"*}"'						\
+		'"${line%\
+%'"'"'/*'"'"'*}"'				\
+		'${line\
+%\
+/\*\
+*\
+}'						\
+		'${line%"/*\
+"*\
+}'						\
+		'${line\
+%\
+'"'"'/*'"'"'*}'					\
+		'"$\
+{li\
+ne%\
+'"'"'/*'"'"'*}"'
+	do
+		atf_check -o inline:":$stripped:\n" -e empty ${TEST_SH} -c \
+			"line='${line}'; echo :${exp}:"
+	done
+}
+
 atf_test_case varpattern_backslashes
 varpattern_backslashes_head() {
 	atf_set "descr" "Tests that protecting wildcards with backslashes" \
@@ -896,6 +940,7 @@ atf_init_test_cases() {
 	atf_add_test_case iteration_on_null_or_missing_parameter
 	atf_add_test_case shell_params
 	atf_add_test_case strip
+	atf_add_test_case wrap_strip
 	atf_add_test_case var_with_embedded_cmdsub
 	atf_add_test_case varpattern_backslashes
 }

Reply via email to