t5545: enhance test coverage when no http server is installed
In commit 438fc68462 ("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 <ramsay@ramsayjones.plus.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
May 16, 2017 at 20:11 UTC
2e397e4ddfff1fcb13b41665b9a3aed6bb99eea2
1 file changed
+43
-42
t/t5545-push-options.sh
+43
-42
@@ -3,8 +3,6 @@
3
test_description='pushing to a repository using push options'
4
5
. ./test-lib.sh
6
-. "$TEST_DIRECTORY"/lib-httpd.sh
7
-start_httpd
6
7
mk_repo_pair () {
8
rm -rf workbench upstream &&
@@ -102,46 +100,6 @@ test_expect_success 'two push options work' '
100
test_cmp expect upstream/.git/hooks/post-receive.push_options
101
'
102
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
-
103
test_expect_success 'push options and submodules' '
104
test_when_finished "rm -rf parent" &&
105
test_when_finished "rm -rf parent_upstream" &&
@@ -182,6 +140,49 @@ test_expect_success 'push options and submodules' '
140
test_cmp expect parent_upstream/.git/hooks/post-receive.push_options
141
'
142
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
+
186
stop_httpd
187
188
test_done