Skip to content

Commit 75318a3

Browse files
peffgitster
authored andcommitted
test scripts: refactor start_httpd helper
There are some redirects and some error checking that need to be done by the caller; let's move both into the start_httpd function so that all callers don't have to repeat them (there is only one caller now, but another will follow in this series). This doesn't violate any assumptions that aren't already being made by lib-httpd, which is happy to say "skipping" and call test_done for a number of other cases. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Jay Soffian <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 661763a commit 75318a3

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

t/lib-httpd.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,18 @@ prepare_httpd() {
9494
}
9595

9696
start_httpd() {
97-
prepare_httpd
97+
prepare_httpd >&3 2>&4
9898

9999
trap 'stop_httpd; die' EXIT
100100

101101
"$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
102102
-f "$TEST_PATH/apache.conf" $HTTPD_PARA \
103-
-c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start
103+
-c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start \
104+
>&3 2>&4
105+
if ! test $? = 0; then
106+
say "skipping test, web server setup failed"
107+
test_done
108+
fi
104109
}
105110

106111
stop_httpd() {

t/t5540-http-push.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,7 @@ then
2020
fi
2121

2222
. "$TEST_DIRECTORY"/lib-httpd.sh
23-
24-
if ! start_httpd >&3 2>&4
25-
then
26-
say "skipping test, web server setup failed"
27-
test_done
28-
exit
29-
fi
23+
start_httpd
3024

3125
test_expect_success 'setup remote repository' '
3226
cd "$ROOT_PATH" &&

0 commit comments

Comments
 (0)