Source-Changes-HG archive

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

[src/trunk]: src/tests/bin/sh Correct one test that (while OK for NetBSD) ins...



details:   https://anonhg.NetBSD.org/src/rev/948bcafe469b
branches:  trunk
changeset: 343990:948bcafe469b
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Mar 08 14:20:22 2016 +0000

description:
Correct one test that (while OK for NetBSD) insisted on behaviour
that is not required by the standard. The test now allows either
of the two allowed responses. Also add commentary correcting
erroneous comments about what is correct, and incorrect. (from kre)

diffstat:

 tests/bin/sh/t_set_e.sh |  36 ++++++++++++++++++++++++++----------
 1 files changed, 26 insertions(+), 10 deletions(-)

diffs (100 lines):

diff -r dea7ed2042d4 -r 948bcafe469b tests/bin/sh/t_set_e.sh
--- a/tests/bin/sh/t_set_e.sh   Tue Mar 08 14:19:28 2016 +0000
+++ b/tests/bin/sh/t_set_e.sh   Tue Mar 08 14:20:22 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_set_e.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $
+# $NetBSD: t_set_e.sh,v 1.2 2016/03/08 14:20:22 christos Exp $
 #
 # Copyright (c) 2007 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -30,7 +30,7 @@
 #   http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
 
 # the implementation of "sh" to test
-: ${TEST_SH:="sh"}
+: ${TEST_SH:="/bin/sh"}
 
 failwith()
 {
@@ -205,6 +205,9 @@
 
        # According to dsl@ in PR bin/32282, () is not defined as a
        # subshell, only as a grouping operator [and a scope, I guess]
+
+       #               (This is incorrect.   () is definitely a sub-shell)
+
        # so the nested false ought to cause the whole shell to exit,
        # not just the subshell. dholland@ would like to see C&V,
        # because that seems like a bad idea. (Among other things, it
@@ -215,8 +218,10 @@
        #
        # XXX: the second set has been disabled in the name of making
        # all tests "pass".
+       #
+       # As they should be, they are utter nonsense.
 
-       # 1. error if the whole shell exits (current behavior)
+       # 1. error if the whole shell exits (current correct behavior)
        dcheck 'echo OK; (set -e; false); echo OK' 'OK OK'
        echeck 'echo OK; (set -e; false); echo OK' 'OK OK'
        # 2. error if the whole shell does not exit (dsl's suggested behavior)
@@ -232,29 +237,32 @@
 
        # backquote expansion (PR bin/17514)
 
-       # correct
+       # (in-)correct
        #dcheck '(set -e; echo ERR `false`; echo ERR); echo OK' 'OK'
        #dcheck '(set -e; echo ERR $(false); echo ERR); echo OK' 'OK'
        #dcheck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'OK'
        #dcheck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'OK'
-       # wrong current behavior
+       # Not-wrong current behavior
+       # the exit status of ommand substitution is ignored in most cases
+       # None of these should be causing the shell to exit.
        dcheck '(set -e; echo ERR `false`; echo ERR); echo OK' 'ERR ERR OK'
        dcheck '(set -e; echo ERR $(false); echo ERR); echo OK' 'ERR ERR OK'
        dcheck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'ERR ERR OK'
        dcheck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'ERR ERR OK'
 
+       # This is testing one case (the case?) where the exit status is used
        dcheck '(set -e; x=`false`; echo ERR); echo OK' 'OK'
        dcheck '(set -e; x=$(false); echo ERR); echo OK' 'OK'
        dcheck '(set -e; x=`exit 3`; echo ERR); echo OK' 'OK'
        dcheck '(set -e; x=$(exit 3); echo ERR); echo OK' 'OK'
 
-       # correct
+       # correct (really just commented out incorrect nonsense)
        #echeck '(set -e; echo ERR `false`; echo ERR); echo OK' 'OK'
        #echeck '(set -e; echo ERR $(false); echo ERR); echo OK' 'OK'
        #echeck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'OK'
        #echeck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'OK'
 
-       # wrong current behavior
+       # not-wrong current behavior (as above)
        echeck '(set -e; echo ERR `false`; echo ERR); echo OK' 'ERR ERR OK'
        echeck '(set -e; echo ERR $(false); echo ERR); echo OK' 'ERR ERR OK'
        echeck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'ERR ERR OK'
@@ -267,11 +275,19 @@
 
        # shift (PR bin/37493)
        # correct
+       # Actually, both ways are correct, both are permitted
        #dcheck '(set -e; shift || true; echo OK); echo OK' 'OK OK'
        #echeck '(set -e; shift || true; echo OK); echo OK' 'OK OK'
-       # wrong current behavior
-       dcheck '(set -e; shift || true; echo OK); echo OK' 'OK'
-       echeck '(set -e; shift || true; echo OK); echo OK' 'OK'
+       # (not-) wrong current behavior
+       #dcheck '(set -e; shift || true; echo OK); echo OK' 'OK'
+       #echeck '(set -e; shift || true; echo OK); echo OK' 'OK'
+
+       # what is wrong is this test assuming one behaviour or the other
+       # (and incidentally this has nothing whatever to do with "-e",
+       # the test should really be moved elsewhere...)
+       # But for now, leave it here, and correct it:
+       dcheck '(set -e; shift && echo OK); echo OK' 'OK'
+       echeck '(set -e; shift && echo OK); echo OK' 'OK'
 
        # Done.
 



Home | Main Index | Thread Index | Old Index