Thread (5 messages) flat view 5 messages, 3 authors, 2016-06-15

Re: [PATCH 1/2] t/test-lib.sh: support Korn shell by converting GIT_EXIT_OK to GIT_EXIT_CODE

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:47:30

Brandon Casey wrote:
So, rather than relying on the behavior of Bash in order to get the exit
code from $? inside die(), change GIT_EXIT_OK into GIT_EXIT_CODE, and set
it to the code that we want to exit with.  This allows the test suite to
be run with the Korn shell.

Signed-off-by: Brandon Casey <redacted>
Sounds like a good idea.  A few thoughts:

start_httpd() from lib-httpd.sh uses a similar pattern:

lib-httpd.sh:96:        trap 'code=$?; stop_httpd; (exit $code); die' EXIT

It is probably worth changing that, too, unless GIT_TEST_HTTPD would not
work on these platforms for some other reason.

"GIT_EXIT_CODE=1; exit 1" sounds repetitive to my ear.  It’s probably just
me, but if not, it might be worth adding a function like

	expected_exit() {
		GIT_EXIT_CODE=$1
		exit "$1"
	}

I’m not sure.
quoted hunk ↗ jump to hunk
diff --git a/t/test-lib.sh b/t/test-lib.sh
index f2ca536..64e793a 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
[...]
quoted hunk ↗ jump to hunk
@@ -183,16 +183,16 @@ test_success=0
 
 die () {
 	code=$?
-	if test -n "$GIT_EXIT_OK"
+	if test -n "$GIT_EXIT_CODE"
 	then
-		exit $code
+		exit $GIT_EXIT_CODE
 	else
 		echo >&5 "FATAL: Unexpected exit with code $code"
 		exit 1
 	fi
 }
$code can be removed now, right?

Jonathan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help