Skip to content

Commit 119c8ee

Browse files
peffgitster
authored andcommitted
add basic http clone/fetch tests
This was mostly being tested implicitly by the "http push" tests. But making a separate test script means that: - we will run fetch tests even when http pushing support is not built - when there are failures on fetching, they are easier to see and isolate, as they are not in the middle of push tests This script defaults to running the webserver on port 5550, and puts the original t5540 on port 5540, so that the two can be run simultaneously without conflict (but both still respect an externally set LIB_HTTPD_PORT). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Jay Soffian <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 75318a3 commit 119c8ee

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,7 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
13631363
GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
13641364
@echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
13651365
@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
1366+
@echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
13661367

13671368
### Detect Tck/Tk interpreter path changes
13681369
ifndef NO_TCLTK

t/t5540-http-push.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This test runs various sanity checks on http-push.'
1111

1212
ROOT_PATH="$PWD"
1313
LIB_HTTPD_DAV=t
14+
LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5540'}
1415

1516
if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
1617
then

t/t5550-http-fetch.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/sh
2+
3+
test_description='test fetching over http'
4+
. ./test-lib.sh
5+
6+
if test -n "$NO_CURL"; then
7+
say 'skipping test, git built without http support'
8+
test_done
9+
fi
10+
11+
. "$TEST_DIRECTORY"/lib-httpd.sh
12+
LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5550'}
13+
start_httpd
14+
15+
test_expect_success 'setup repository' '
16+
echo content >file &&
17+
git add file &&
18+
git commit -m one
19+
'
20+
21+
test_expect_success 'create http-accessible bare repository' '
22+
mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
23+
(cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
24+
git --bare init &&
25+
echo "exec git update-server-info" >hooks/post-update &&
26+
chmod +x hooks/post-update
27+
) &&
28+
git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
29+
git push public master:master
30+
'
31+
32+
test_expect_success 'clone http repository' '
33+
git clone $HTTPD_URL/repo.git clone &&
34+
test_cmp file clone/file
35+
'
36+
37+
test_expect_success 'fetch changes via http' '
38+
echo content >>file &&
39+
git commit -a -m two &&
40+
git push public
41+
(cd clone && git pull) &&
42+
test_cmp file clone/file
43+
'
44+
45+
stop_httpd
46+
test_done

0 commit comments

Comments
 (0)