Test suite: Regression fix - wait_until should not run command in sub-shell.
authorMartin Schwenke <martin@meltin.net>
Wed, 28 Oct 2009 02:02:18 +0000 (13:02 +1100)
committerMartin Schwenke <martin@meltin.net>
Wed, 28 Oct 2009 02:02:18 +0000 (13:02 +1100)
Commit 25e82a8a667a54c6921ef076c63fdd738dd75d19 changed wait_until()
to protect the command it runs from "set -e" by running it in a
subshell.  This breaks uses where the command is expected to set
global variables.  For example, wait_until_get_src_socket lost the
value of $out from its call to get_src_socket().

The fix is to not be lazy and use a sub-shell!

Signed-off-by: Martin Schwenke <martin@meltin.net>
tests/scripts/ctdb_test_functions.bash

index e554680f0a1277120c305607af89a783340a7337..832a42bf16892907a874dc822a581aa304857579 100644 (file)
@@ -297,8 +297,8 @@ wait_until ()
     echo -n "<${timeout}|"
     local t=$timeout
     while [ $t -gt 0 ] ; do
-       ("$@")
-       local rc=$?
+       local rc=0
+       "$@" || rc=$?
        if { ! $negate && [ $rc -eq 0 ] ; } || \
            { $negate && [ $rc -ne 0 ] ; } ; then
            echo "|$(($timeout - $t))|"