tests: use 'test_atexit' to stop httpd

Use 'test_atexit' to run cleanup commands to stop httpd at the end of
the test script or upon interrupt or failure, as it is shorter,
simpler, and more robust than registering such cleanup commands in the
trap on EXIT in the test scripts.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
SZEDER Gábor
2019-03-13 13:24:13 +01:00
committed by Junio C Hamano
parent 9f82b2a6a7
commit 8c3b9f7faa
25 changed files with 1 additions and 50 deletions

View File

@ -14,7 +14,6 @@
#
# test_expect_success ...
#
# stop_httpd
# test_done
#
# Can be configured using the following variables.
@ -176,7 +175,7 @@ prepare_httpd() {
start_httpd() {
prepare_httpd >&3 2>&4
trap 'code=$?; stop_httpd; (exit $code); die' EXIT
test_atexit stop_httpd
"$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
-f "$TEST_PATH/apache.conf" $HTTPD_PARA \
@ -184,15 +183,12 @@ start_httpd() {
>&3 2>&4
if test $? -ne 0
then
trap 'die' EXIT
cat "$HTTPD_ROOT_PATH"/error.log >&4 2>/dev/null
test_skip_or_die $GIT_TEST_HTTPD "web server setup failed"
fi
}
stop_httpd() {
trap 'die' EXIT
"$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
-f "$TEST_PATH/apache.conf" $HTTPD_PARA -k stop
}