summaryrefslogtreecommitdiff
path: root/portland
diff options
context:
space:
mode:
authorTom Whipple <tw@tomwhipple.com>2006-07-26 23:38:08 +0000
committerTom Whipple <tw@tomwhipple.com>2006-07-26 23:38:08 +0000
commitf3d340b9ac0a3fed36d42f15b0e2ae6351e77c03 (patch)
tree5ad250e7aa52dc0a326335c3211cd70d239ae941 /portland
parentdf5c0a3574c0280e7713883dffa18375f4810e52 (diff)
add ability to save response in assert_interactive and adjust assert_nostderr to accomodate XDG_UTILS_DEBUG_LEVEL
Diffstat (limited to 'portland')
-rw-r--r--portland/xdg-utils/tests/include/testassertions.sh33
1 files changed, 23 insertions, 10 deletions
diff --git a/portland/xdg-utils/tests/include/testassertions.sh b/portland/xdg-utils/tests/include/testassertions.sh
index 7642fdf..d064faa 100644
--- a/portland/xdg-utils/tests/include/testassertions.sh
+++ b/portland/xdg-utils/tests/include/testassertions.sh
@@ -9,6 +9,9 @@ assert_exit() # execute command (saving output) and check exit code
EXPECT="$1"
shift 1
+ # make sure nothing is hanging around from a prev. test.
+ rm -f out.stdout out.stderr
+
# $1 is command, $2 is expected exit code (0 or "N" for non-zero)
( "$@" > out.stdout 2> out.stderr )
CODE="$?"
@@ -45,20 +48,28 @@ assert_interactive() {
return
fi
- echo -ne "\n\t" >&2
if [ ! -z "$expect" ] ; then
- if [ "$expect" != y -a "$expect" != n ] ; then
- echo "TEST SYNTAX ERROR: interactive assertions require 'y' or 'n' as choices. (found '$expect')"
+ if [ "$expect" != y -a "$expect" != n -a "$expect" != s ] ; then
+ echo "TEST SYNTAX ERROR: interactive assertions require one of (y,n,s) as choices. (found '$expect')" >&2
exit 255
fi
- echo -n "$query [y/n]: " >&2
- read result
-
- if [ "$result" != "$expect" ] ; then
+ unset result
+ while [ "$result" != y -a "$result" != n ] ; do
+ echo -ne "\n\t$query [y/n]: " >&2
+ read result
+ done
+
+ if [ "$expect" = s ] ; then
+ if [ -z "$3" ] ; then
+ echo "TEST SYNTAX ERROR: 's' requires a variable name"
+ exit 255
+ fi
+ eval "$3=$result"
+ elif [ "$result" != "$expect" ] ; then
test_fail "User indicated '$result' instead of '$expect' in respnonse to '$query'"
fi
else
- echo -n "$query [enter to continue] " >&2
+ echo -ne "\n\t$query [enter to continue] " >&2
read result
fi
}
@@ -116,8 +127,10 @@ assert_nostdout() # check that nothing went to stdout
assert_nostderr() # check that nothing went to stderr
{
- if [ -s out.stderr ]
- then
+ if [ ! -z "$XDG_UTILS_DEBUG_LEVEL" ] ; then
+ test_infoline "not checking STDERR because XDG_UTILS_DEBUG_LEVEL=$XDG_UTILS_DEBUG_LEVEL"
+ test_infoline out.stderr stderr:
+ elif [ -s out.stderr ] ; then
test_infoline "Unexpected output written to stderr, as shown below:"
infofile out.stderr stderr:
test_fail