From d0d692e4153bbcb53683eff1a782182d8bafaa4e Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 4 Jan 2014 12:53:10 +0100 Subject: [PATCH] tests: New helper function feed_input, for comment support feed_input drops lines starting with a bar character '|', so they can serve as comments. Syntax chosen because such lines shouldn't be needed in tests. In particular, the server already ignores such lines when it reads commands, because they get parsed as empty command with a pipeline, and empty commands get ignored, regardless of redirections. Signed-off-by: Markus Armbruster --- tests/actofgod-test | 3 +-- tests/smoke-test | 6 +++--- tests/test-common.sh | 8 ++++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/actofgod-test b/tests/actofgod-test index 01abc3ff..66925084 100755 --- a/tests/actofgod-test +++ b/tests/actofgod-test @@ -31,9 +31,8 @@ EOF begin_test "$srcdir"/tests/actofgod/init_script -perl "$srcdir"/tests/actofgod/geninput.pl | src/client/empire POGO peter >/dev/null +perl "$srcdir"/tests/actofgod/geninput.pl | feed_input POGO peter end_test -# Test completed; compare results cmp_out var/empire/server.log var/empire/journal.log actofgod.xdump diff --git a/tests/smoke-test b/tests/smoke-test index f4717827..e75fb390 100755 --- a/tests/smoke-test +++ b/tests/smoke-test @@ -27,7 +27,7 @@ create_sandbox begin_test "$srcdir"/tests/smoke/fairland.xdump -src/client/empire POGO peter <"$srcdir"/tests/smoke/newcap_script >/dev/null +feed_input POGO peter "$srcdir"/tests/smoke/newcap_script t= for i in `git ls-files "$srcdir"/tests/smoke | grep 'tests/smoke/../..$'` @@ -36,7 +36,7 @@ do t="${i%/??}" if [ "$p" != "$t" ] && [ "$p" ] then - src/client/empire POGO peter </dev/null + feed_input POGO peter </dev/null + feed_input "$c" "$r" "$i" done end_test diff --git a/tests/test-common.sh b/tests/test-common.sh index bc0d1a0f..9ddd7f84 100644 --- a/tests/test-common.sh +++ b/tests/test-common.sh @@ -70,6 +70,14 @@ stop_server() done } +feed_input() +{ + c=$1 + r=$2 + shift 2 + sed '/^|/d' "$@" | src/client/empire "$c" "$r" >/dev/null +} + begin_test() { src/util/files -e sandbox/etc/empire/econfig -f >/dev/null