Thread (32 messages) flat view 32 messages, 5 authors, 2016-08-13
STALE3674d

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

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:49:43
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Jonathan Nieder <redacted>
---
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help