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

@ -76,11 +76,6 @@ maybe_start_httpd () {
LIB_HTTPD_SVN="$loc"
start_httpd
;;
*)
stop_httpd () {
: noop
}
;;
esac
}

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
}

View File

@ -518,6 +518,4 @@ test_expect_success 'fetching of missing objects from an HTTP server' '
git verify-pack --verbose "$IDX" | grep "$HASH"
'
stop_httpd
test_done

View File

@ -918,7 +918,4 @@ test_expect_success 'fetch with --filter=blob:limit=0 and HTTP' '
fetch_filter_blob_limit_zero "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
'
stop_httpd
test_done

View File

@ -978,6 +978,4 @@ test_expect_success '--negotiation-tip limits "have" lines sent with HTTP protoc
check_negotiation_tip
'
stop_httpd
test_done

View File

@ -255,6 +255,4 @@ test_expect_success 'shallow fetches check connectivity before writing shallow f
git -C client fsck
'
stop_httpd
test_done

View File

@ -146,5 +146,4 @@ test_expect_success 'fetching deepen' '
)
'
stop_httpd
test_done

View File

@ -176,6 +176,4 @@ test_expect_failure 'push to password-protected repository (no user in URL)' '
test_cmp expect actual
'
stop_httpd
test_done

View File

@ -373,5 +373,4 @@ test_expect_success 'colorize errors/hints' '
test_i18ngrep ! "^hint: " decoded
'
stop_httpd
test_done

View File

@ -90,5 +90,4 @@ EOF
)
'
stop_httpd
test_done

View File

@ -278,6 +278,4 @@ test_expect_success 'push options keep quoted characters intact (http)' '
test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/pre-receive.push_options
'
stop_httpd
test_done

View File

@ -408,5 +408,4 @@ test_expect_success 'print HTTP error when any intermediate redirect throws erro
test_i18ngrep "unable to access.*/redir-to/502" stderr
'
stop_httpd
test_done

View File

@ -434,5 +434,4 @@ test_expect_success 'server-side error detected' '
grep "server-side error" actual
'
stop_httpd
test_done

View File

@ -132,5 +132,4 @@ test_expect_success 'server request log matches test results' '
check_access_log exp
'
stop_httpd
test_done

View File

@ -23,6 +23,4 @@ test_expect_success 'failure in git-upload-pack is shown' '
grep "< HTTP/1.1 500 Intentional Breakage" curl_log
'
stop_httpd
test_done

View File

@ -733,6 +733,4 @@ test_expect_success 'partial clone using HTTP' '
partial_clone "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
'
stop_httpd
test_done

View File

@ -331,6 +331,4 @@ test_expect_success 'when partial cloning, tolerate server not sending target of
! test -e "$HTTPD_ROOT_PATH/one-time-sed"
'
stop_httpd
test_done

View File

@ -289,6 +289,4 @@ test_expect_success 'push with http:// using protocol v1' '
grep "git< version 1" log
'
stop_httpd
test_done

View File

@ -687,6 +687,4 @@ test_expect_success 'when server does not send "ready", expect FLUSH' '
test_i18ngrep "expected no other sections to be sent after no .ready." err
'
stop_httpd
test_done

View File

@ -257,8 +257,6 @@ test_expect_success 'server loses a ref - ref in want' '
test_i18ngrep "fatal: remote error: unknown ref refs/heads/raster" err
'
stop_httpd
REPO="$(pwd)/repo"
LOCAL_PRISTINE="$(pwd)/local_pristine"

View File

@ -34,5 +34,4 @@ test_expect_success 'http can be limited to from-user' '
clone "$HTTPD_URL/smart-redir-perm/repo.git" redir.git
'
stop_httpd
test_done

View File

@ -120,6 +120,4 @@ test_expect_success !MINGW,!UTF8_NFD_TO_NFC 'svn.pathnameencoding=cp932 rename o
git svn dcommit
'
stop_httpd
test_done

View File

@ -87,6 +87,4 @@ test_expect_success 'test dcommit to trailing_dotlock branch' '
)
'
stop_httpd
test_done

View File

@ -74,6 +74,4 @@ test_expect_success 'test clone -s with unescaped space' '
)
'
stop_httpd
test_done

View File

@ -26,6 +26,4 @@ test_expect_success 'clone trunk with "-r HEAD"' '
( cd g && git rev-parse --symbolic --verify HEAD )
'
stop_httpd
test_done