Skip to content

Commit 8a5732c

Browse files
committed
Merge branch 'jc/skip-test-in-the-middle' into maint
A recent update to t5545-push-options.sh started skipping all the tests in the script when a web server testing is disabled or unavailable, not just the ones that require a web server. Non HTTP tests have been salvaged to always run in this script. * jc/skip-test-in-the-middle: t5545: enhance test coverage when no http server is installed test: allow skipping the remainder
2 parents e350625 + 2e397e4 commit 8a5732c

File tree

2 files changed

+56
-50
lines changed

2 files changed

+56
-50
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

t/test-lib.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -745,20 +745,25 @@ test_done () {
745745
fi
746746
case "$test_failure" in
747747
0)
748-
# Maybe print SKIP message
749-
if test -n "$skip_all" && test $test_count -gt 0
750-
then
751-
error "Can't use skip_all after running some tests"
752-
fi
753-
test -z "$skip_all" || skip_all=" # SKIP $skip_all"
754-
755748
if test $test_external_has_tap -eq 0
756749
then
757750
if test $test_remaining -gt 0
758751
then
759752
say_color pass "# passed all $msg"
760753
fi
761-
say "1..$test_count$skip_all"
754+
755+
# Maybe print SKIP message
756+
test -z "$skip_all" || skip_all="# SKIP $skip_all"
757+
case "$test_count" in
758+
0)
759+
say "1..$test_count${skip_all:+ $skip_all}"
760+
;;
761+
*)
762+
test -z "$skip_all" ||
763+
say_color warn "$skip_all"
764+
say "1..$test_count"
765+
;;
766+
esac
762767
fi
763768

764769
test -d "$remove_trash" &&

0 commit comments

Comments
 (0)