Skip to content

Commit 6cdffd0

Browse files
peffgitster
authored andcommitted
t5545: factor out http repository setup
We repeat many lines of setup code in the two http tests, and further tests would need to repeat it again. Let's factor this out into a function. Incidentally, this also fixes an unlikely bug: if the httpd root path contains a double-quote, our test_when_finished would barf due to improper quoting (we escape the embedded quotes, but not the $, meaning we expand the variable before the eval). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ffa9524 commit 6cdffd0

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

t/t5545-push-options.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,28 +220,28 @@ test_expect_success 'invalid push option in config' '
220220
. "$TEST_DIRECTORY"/lib-httpd.sh
221221
start_httpd
222222

223-
test_expect_success 'push option denied properly by http server' '
223+
# set up http repository for fetching/pushing, with push options config
224+
# bool set to $1
225+
mk_http_pair () {
224226
test_when_finished "rm -rf test_http_clone" &&
225-
test_when_finished "rm -rf \"$HTTPD_DOCUMENT_ROOT_PATH\"/upstream.git" &&
227+
test_when_finished 'rm -rf "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git' &&
226228
mk_repo_pair &&
227-
git -C upstream config receive.advertisePushOptions false &&
229+
git -C upstream config receive.advertisePushOptions "$1" &&
228230
git -C upstream config http.receivepack true &&
229231
cp -R upstream/.git "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git &&
230-
git clone "$HTTPD_URL"/smart/upstream test_http_clone &&
232+
git clone "$HTTPD_URL"/smart/upstream test_http_clone
233+
}
234+
235+
test_expect_success 'push option denied properly by http server' '
236+
mk_http_pair false &&
231237
test_commit -C test_http_clone one &&
232238
test_must_fail git -C test_http_clone push --push-option=asdf origin master 2>actual &&
233239
test_i18ngrep "the receiving end does not support push options" actual &&
234240
git -C test_http_clone push origin master
235241
'
236242

237243
test_expect_success 'push options work properly across http' '
238-
test_when_finished "rm -rf test_http_clone" &&
239-
test_when_finished "rm -rf \"$HTTPD_DOCUMENT_ROOT_PATH\"/upstream.git" &&
240-
mk_repo_pair &&
241-
git -C upstream config receive.advertisePushOptions true &&
242-
git -C upstream config http.receivepack true &&
243-
cp -R upstream/.git "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git &&
244-
git clone "$HTTPD_URL"/smart/upstream test_http_clone &&
244+
mk_http_pair true &&
245245
246246
test_commit -C test_http_clone one &&
247247
git -C test_http_clone push origin master &&

0 commit comments

Comments
 (0)