]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tests: use 'test_atexit' to stop httpd
authorSZEDER Gábor <szeder.dev@gmail.com>
Wed, 13 Mar 2019 12:24:13 +0000 (13:24 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Mar 2019 03:34:39 +0000 (12:34 +0900)
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>
25 files changed:
t/lib-git-svn.sh
t/lib-httpd.sh
t/t0410-partial-clone.sh
t/t5500-fetch-pack.sh
t/t5510-fetch.sh
t/t5537-fetch-shallow.sh
t/t5539-fetch-http-shallow.sh
t/t5540-http-push-webdav.sh
t/t5541-http-push-smart.sh
t/t5542-push-http-shallow.sh
t/t5545-push-options.sh
t/t5550-http-fetch-dumb.sh
t/t5551-http-fetch-smart.sh
t/t5561-http-backend.sh
t/t5581-http-curl-verbose.sh
t/t5601-clone.sh
t/t5616-partial-clone.sh
t/t5700-protocol-v1.sh
t/t5702-protocol-v2.sh
t/t5703-upload-pack-ref-in-want.sh
t/t5812-proto-disable-http.sh
t/t9115-git-svn-dcommit-funky-renames.sh
t/t9118-git-svn-funky-branch-names.sh
t/t9120-git-svn-clone-with-percent-escapes.sh
t/t9142-git-svn-shallow-clone.sh

index f3b478c307c99397fb180fb3d5688e1d6f257904..c1271d686372dfd46d640a84ebec3971933ed4f2 100644 (file)
@@ -76,11 +76,6 @@ maybe_start_httpd () {
                LIB_HTTPD_SVN="$loc"
                start_httpd
                ;;
-       *)
-               stop_httpd () {
-                       : noop
-               }
-               ;;
        esac
 }
 
index 0dfb48c2f6df78348c216bd34693758c0d22365d..b3cc62bd36f26f776b307607a941b01c547c404d 100644 (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
 }
index bce02788e6e1b03b87911fb13594e0cf6f80fdab..5bd892f2f7a90ac9e35993c137e0addd10d17bde 100755 (executable)
@@ -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
index 49c540b1e1dbd5fc7d9a7baa36ee93a2ed3fc3c3..32426fa5d1d4e62450f97543b72623fea2b00189 100755 (executable)
@@ -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
index 3b7b30568cddd5d9ea1a8979e5366a262f81bf09..e98d90dd9baf644bf2013aea51a91eab4e9ef73c 100755 (executable)
@@ -978,6 +978,4 @@ test_expect_success '--negotiation-tip limits "have" lines sent with HTTP protoc
        check_negotiation_tip
 '
 
-stop_httpd
-
 test_done
index 6caf628efaaa400473ddfb46fdef0b847b4edd39..66f0b64d39273d9e2f6ae5c74e195e50e4b712c5 100755 (executable)
@@ -255,6 +255,4 @@ test_expect_success 'shallow fetches check connectivity before writing shallow f
        git -C client fsck
 '
 
-stop_httpd
-
 test_done
index 5fbf67c4468897184f46ef9ea151f1dd6ad1d8d0..98f028f2036e3b0c8712790b93b760d164bd3628 100755 (executable)
@@ -146,5 +146,4 @@ test_expect_success 'fetching deepen' '
        )
 '
 
-stop_httpd
 test_done
index 88ff5a49e4af38daca65c6e3a79ea4030b391c6b..a094fd5e71334bd16ac890234962485a7f9b7d24 100755 (executable)
@@ -176,6 +176,4 @@ test_expect_failure 'push to password-protected repository (no user in URL)' '
        test_cmp expect actual
 '
 
-stop_httpd
-
 test_done
index 5475afc052934677c4f87adf4f29da507b4c6844..bdf40f445e969502e0a52b925acc8d6d0b9d49da 100755 (executable)
@@ -373,5 +373,4 @@ test_expect_success 'colorize errors/hints' '
        test_i18ngrep ! "^hint: " decoded
 '
 
-stop_httpd
 test_done
index 51658331571611c568def54be28072f426c48e66..ddc1db722d43ce3cfbf80b46deea0a69a4973247 100755 (executable)
@@ -90,5 +90,4 @@ EOF
        )
 '
 
-stop_httpd
 test_done
index b47a95871cac3dd8593b3b9262d238be3914ac62..6d1d59c9b1af8c1ca7d6e78c8a589395ff971338 100755 (executable)
@@ -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
index 6d7d88ccc906a4c73285550ec80cd3fe67a764ee..57f6f8c6286774815e00e038a9683e0afafbe409 100755 (executable)
@@ -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
index ba83e567e5ca49c1664fe13f447e2744d55bfb3a..9faf6349cf1c606ba1efa622d294cff174b368ec 100755 (executable)
@@ -434,5 +434,4 @@ test_expect_success 'server-side error detected' '
        grep "server-side error" actual
 '
 
-stop_httpd
 test_done
index 1c49054595c23564cf762ac01ea0a1667a59f2f9..6eb0294978a03f35f5c246a6000a92fc377b02ed 100755 (executable)
@@ -132,5 +132,4 @@ test_expect_success 'server request log matches test results' '
        check_access_log exp
 '
 
-stop_httpd
 test_done
index cd9283eeecd9d5d65ec5713b260d254679939fa8..5129b0724f703890c80c8dcbe7bd4347792963e3 100755 (executable)
@@ -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
index d6948cbdab03cf827d86511ade26366e89fda149..b04d66868490e2db67ceee695498c921237b30ba 100755 (executable)
@@ -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
index 9643acb1615fe0d28a7f0e386fa69a570a93dc8e..9a8f9886b3e2d82b5c10bf749d485f05bd364db6 100755 (executable)
@@ -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
index ba86a44eb183921e844dff6f9d6a5bb27c7d5e91..b0e4752232cdf1d6807a78968c1f9c22f507f217 100755 (executable)
@@ -289,6 +289,4 @@ test_expect_success 'push with http:// using protocol v1' '
        grep "git< version 1" log
 '
 
-stop_httpd
-
 test_done
index e112b6086c96e4cb0ad7bc10dcd685e7570d496f..a0896593375803eb79782705a21d673c72172c83 100755 (executable)
@@ -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
index f87b2f6df329975e243ab9c00b510ee4cc588d0b..b6a995e8579c91874d2850ca579f87bf93f40561 100755 (executable)
@@ -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"
 
index 872788ac8ca4ecc0a54c14a04e3f72661306f1d3..af8772fadaa0d590370ba8a28b33c5b455164312 100755 (executable)
@@ -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
index 64bb495834698c8438c8b8dde488873072abc1fd..9b44a44bc1f917e2a05956e3300e2cb673a3fec3 100755 (executable)
@@ -120,6 +120,4 @@ test_expect_success !MINGW,!UTF8_NFD_TO_NFC 'svn.pathnameencoding=cp932 rename o
        git svn dcommit
 '
 
-stop_httpd
-
 test_done
index 41a026637fa03174765d4e3facc3815bbf538e29..a159ff96b71882362eaa7d7856289561601674cf 100755 (executable)
@@ -87,6 +87,4 @@ test_expect_success 'test dcommit to trailing_dotlock branch' '
        )
        '
 
-stop_httpd
-
 test_done
index b28a1741e3f52296dcab35ed6d51fa01c2628652..40b714df31a20f5b6908ca69dd229d624bc775cc 100755 (executable)
@@ -74,6 +74,4 @@ test_expect_success 'test clone -s with unescaped space' '
        )
 '
 
-stop_httpd
-
 test_done
index 9ee23be64003ab22277c80a6c4b364c8cc36f902..a30730502d859408a3d59a1859e55a07eac0c6ce 100755 (executable)
@@ -26,6 +26,4 @@ test_expect_success 'clone trunk with "-r HEAD"' '
        ( cd g && git rev-parse --symbolic --verify HEAD )
 '
 
-stop_httpd
-
 test_done