Skip to content

Commit 2e397e4

Browse files
stefanbellergitster
authored andcommitted
t5545: enhance test coverage when no http server is installed
In commit 438fc68 ("push options: pass push options to the transport helper", 08-02-2017), the test coverage was reduced to run no tests at all if you lack a http server. Move the http initialization to the end, such that only http tests are skipped when a http server is missing. The test in between that tests submodule propagation is safe to run before the http tests as it makes its own test directories `parent` and `parent_upstream`. Noticed-by: Ramsay Jones <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c7018be commit 2e397e4

File tree

1 file changed

+43
-42
lines changed

1 file changed

+43
-42
lines changed

t/t5545-push-options.sh

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
test_description='pushing to a repository using push options'
44

55
. ./test-lib.sh
6-
. "$TEST_DIRECTORY"/lib-httpd.sh
7-
start_httpd
86

97
mk_repo_pair () {
108
rm -rf workbench upstream &&
@@ -102,46 +100,6 @@ test_expect_success 'two push options work' '
102100
test_cmp expect upstream/.git/hooks/post-receive.push_options
103101
'
104102

105-
test_expect_success 'push option denied properly by http server' '
106-
test_when_finished "rm -rf test_http_clone" &&
107-
test_when_finished "rm -rf \"$HTTPD_DOCUMENT_ROOT_PATH\"/upstream.git" &&
108-
mk_repo_pair &&
109-
git -C upstream config receive.advertisePushOptions false &&
110-
git -C upstream config http.receivepack true &&
111-
cp -R upstream/.git "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git &&
112-
git clone "$HTTPD_URL"/smart/upstream test_http_clone &&
113-
test_commit -C test_http_clone one &&
114-
test_must_fail git -C test_http_clone push --push-option=asdf origin master 2>actual &&
115-
test_i18ngrep "the receiving end does not support push options" actual &&
116-
git -C test_http_clone push origin master
117-
'
118-
119-
test_expect_success 'push options work properly across http' '
120-
test_when_finished "rm -rf test_http_clone" &&
121-
test_when_finished "rm -rf \"$HTTPD_DOCUMENT_ROOT_PATH\"/upstream.git" &&
122-
mk_repo_pair &&
123-
git -C upstream config receive.advertisePushOptions true &&
124-
git -C upstream config http.receivepack true &&
125-
cp -R upstream/.git "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git &&
126-
git clone "$HTTPD_URL"/smart/upstream test_http_clone &&
127-
128-
test_commit -C test_http_clone one &&
129-
git -C test_http_clone push origin master &&
130-
git -C "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git rev-parse --verify master >expect &&
131-
git -C test_http_clone rev-parse --verify master >actual &&
132-
test_cmp expect actual &&
133-
134-
test_commit -C test_http_clone two &&
135-
git -C test_http_clone push --push-option=asdf --push-option="more structured text" origin master &&
136-
printf "asdf\nmore structured text\n" >expect &&
137-
test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/pre-receive.push_options &&
138-
test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/post-receive.push_options &&
139-
140-
git -C "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git rev-parse --verify master >expect &&
141-
git -C test_http_clone rev-parse --verify master >actual &&
142-
test_cmp expect actual
143-
'
144-
145103
test_expect_success 'push options and submodules' '
146104
test_when_finished "rm -rf parent" &&
147105
test_when_finished "rm -rf parent_upstream" &&
@@ -182,6 +140,49 @@ test_expect_success 'push options and submodules' '
182140
test_cmp expect parent_upstream/.git/hooks/post-receive.push_options
183141
'
184142

143+
. "$TEST_DIRECTORY"/lib-httpd.sh
144+
start_httpd
145+
146+
test_expect_success 'push option denied properly by http server' '
147+
test_when_finished "rm -rf test_http_clone" &&
148+
test_when_finished "rm -rf \"$HTTPD_DOCUMENT_ROOT_PATH\"/upstream.git" &&
149+
mk_repo_pair &&
150+
git -C upstream config receive.advertisePushOptions false &&
151+
git -C upstream config http.receivepack true &&
152+
cp -R upstream/.git "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git &&
153+
git clone "$HTTPD_URL"/smart/upstream test_http_clone &&
154+
test_commit -C test_http_clone one &&
155+
test_must_fail git -C test_http_clone push --push-option=asdf origin master 2>actual &&
156+
test_i18ngrep "the receiving end does not support push options" actual &&
157+
git -C test_http_clone push origin master
158+
'
159+
160+
test_expect_success 'push options work properly across http' '
161+
test_when_finished "rm -rf test_http_clone" &&
162+
test_when_finished "rm -rf \"$HTTPD_DOCUMENT_ROOT_PATH\"/upstream.git" &&
163+
mk_repo_pair &&
164+
git -C upstream config receive.advertisePushOptions true &&
165+
git -C upstream config http.receivepack true &&
166+
cp -R upstream/.git "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git &&
167+
git clone "$HTTPD_URL"/smart/upstream test_http_clone &&
168+
169+
test_commit -C test_http_clone one &&
170+
git -C test_http_clone push origin master &&
171+
git -C "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git rev-parse --verify master >expect &&
172+
git -C test_http_clone rev-parse --verify master >actual &&
173+
test_cmp expect actual &&
174+
175+
test_commit -C test_http_clone two &&
176+
git -C test_http_clone push --push-option=asdf --push-option="more structured text" origin master &&
177+
printf "asdf\nmore structured text\n" >expect &&
178+
test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/pre-receive.push_options &&
179+
test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/post-receive.push_options &&
180+
181+
git -C "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git rev-parse --verify master >expect &&
182+
git -C test_http_clone rev-parse --verify master >actual &&
183+
test_cmp expect actual
184+
'
185+
185186
stop_httpd
186187

187188
test_done

0 commit comments

Comments
 (0)