Subject: [TOY PATCH] test-lib: &&-chaining tester

From: Jonathan Nieder <[email-masked]>
Date: Wed, 6 Oct 2010 00:31:18 -0500

Signed-off-by: Jonathan Nieder <[email-masked]>
---
Hi Elijah,

Elijah Newren wrote:

> This patch series fixes many of the missing &&s in the testsuite.

Thanks again.  Here's a little glimpse of a future without missing &&s
to play with.

 t/test-lib.sh |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 932f45b..e3a0e68 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -393,7 +393,17 @@ test_debug () {
 	test "$debug" = "" || eval "$1"
 }
 
+check_command_chaining_ () {
+	eval >&3 2>&4 "(exit 189) && $1"
+	eval_chain_ret=$?
+	if test "$eval_chain_ret" != 189
+	then
+		error 'bug in the test script: missing "&&" in test commands'
+	fi
+}
+
 test_run_ () {
+	check_command_chaining_ "$1"
 	test_cleanup=:
 	eval >&3 2>&4 "$1"
 	eval_ret=$?
@@ -697,6 +707,7 @@ test_cmp() {
 # the test to pass.
 
 test_when_finished () {
+	check_command_chaining_ "$test_cleanup"
 	test_cleanup="{ $*
 		} && (exit \"\$eval_ret\"); eval_ret=\$?; $test_cleanup"
 }
-- 
1.7.2.3