Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/bin/sh Add a new test case to check for correct parsin...



details:   https://anonhg.NetBSD.org/src/rev/7298741c69b3
branches:  trunk
changeset: 1023460:7298741c69b3
user:      kre <kre%NetBSD.org@localhost>
date:      Thu Sep 09 00:04:51 2021 +0000

description:
Add a new test case to check for correct parsing and execution
of a few bizarre here document usages, such as

        : << do | for x in xxx
        do
        do echo $x
        done

which should work, but never have done.  (See the source for others).

This test case will currently fail, until the bug is fixed
(already done, to be committed very soon).

diffstat:

 tests/bin/sh/t_here.sh |  32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diffs (52 lines):

diff -r 78f55912ac59 -r 7298741c69b3 tests/bin/sh/t_here.sh
--- a/tests/bin/sh/t_here.sh    Wed Sep 08 12:00:50 2021 +0000
+++ b/tests/bin/sh/t_here.sh    Thu Sep 09 00:04:51 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_here.sh,v 1.7 2019/01/22 14:31:53 kre Exp $
+# $NetBSD: t_here.sh,v 1.8 2021/09/09 00:04:51 kre Exp $
 #
 # Copyright (c) 2007 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -530,6 +530,35 @@
                '
 }
 
+# The following tests a problem reported on the austin-list 2021-09-08
+# by oguzismailuysal%gmail.com@localhost ... it affected all ash derived shells
+atf_test_case hard_cases
+hard_cases_head() {
+       atf_set "descr" \
+               "Tests here docs in positions that have confised our parser"
+}
+hard_cases_body() {
+
+       atf_check -s exit:0 -o inline:'xxx\n' -e empty ${TEST_SH} -c '
+               : <<- do | for x in xxx
+               do
+               do echo $x
+               done'
+
+       atf_check -s exit:0 -o inline:'xxx\n' -e empty ${TEST_SH} -c '
+               set -- xxx
+               : <<- done | for x in xxx
+               done
+               do echo $x
+               done'
+
+       atf_check -s exit:0 -o inline:'xxx\n' -e empty ${TEST_SH} -c '
+               : <<- in | case xxx
+               in
+               in xxx) echo xxx;;
+               esac'
+}
+
 atf_test_case vicious
 vicious_head() {
        atf_set "descr" "Tests for obscure and obnoxious uses of here docs"
@@ -600,5 +629,6 @@
        atf_add_test_case nested        # here docs inside here docs
        atf_add_test_case quoting       # stuff quoted inside
        atf_add_test_case side_effects  # here docs that modify environment
+       atf_add_test_case hard_cases    # here doc bodies appearing mid command
        atf_add_test_case vicious       # evil test from the austin-l list...
 }



Home | Main Index | Thread Index | Old Index