]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5800-remote-testpy.sh
kill limit_pathspec_to_literal() as it's only used by parse_pathspec()
[thirdparty/git.git] / t / t5800-remote-testpy.sh
CommitLineData
2cb5a481
SR
1#!/bin/sh
2#
3# Copyright (c) 2010 Sverre Rabbelier
4#
5
d0ac3ffd 6test_description='Test python remote-helper framework'
2cb5a481
SR
7
8. ./test-lib.sh
9
760fec7d 10if ! test_have_prereq PYTHON ; then
d0ac3ffd 11 skip_all='skipping python remote-helper tests, python not available'
760fec7d
SR
12 test_done
13fi
14
15"$PYTHON_PATH" -c '
2bf10334 16import sys
23b093ee 17if sys.hexversion < 0x02040000:
2bf10334 18 sys.exit(1)
760fec7d 19' || {
d0ac3ffd 20 skip_all='skipping python remote-helper tests, python version < 2.4'
760fec7d
SR
21 test_done
22}
63a2f613 23
5cf5ade3
JK
24compare_refs() {
25 git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
26 git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
27 test_cmp expect actual
28}
29
760fec7d 30test_expect_success 'setup repository' '
2cb5a481
SR
31 git init --bare server/.git &&
32 git clone server public &&
33 (cd public &&
34 echo content >file &&
35 git add file &&
36 git commit -m one &&
37 git push origin master)
38'
39
760fec7d 40test_expect_success 'cloning from local repo' '
d0ac3ffd 41 git clone "testpy::${PWD}/server" localclone &&
2cb5a481
SR
42 test_cmp public/file localclone/file
43'
44
760fec7d 45test_expect_success 'cloning from remote repo' '
d0ac3ffd 46 git clone "testpy::file://${PWD}/server" clone &&
2cb5a481
SR
47 test_cmp public/file clone/file
48'
49
760fec7d 50test_expect_success 'create new commit on remote' '
2cb5a481
SR
51 (cd public &&
52 echo content >>file &&
53 git commit -a -m two &&
54 git push)
55'
56
760fec7d 57test_expect_success 'pulling from local repo' '
2cb5a481
SR
58 (cd localclone && git pull) &&
59 test_cmp public/file localclone/file
60'
61
760fec7d 62test_expect_success 'pulling from remote remote' '
2cb5a481
SR
63 (cd clone && git pull) &&
64 test_cmp public/file clone/file
65'
66
760fec7d 67test_expect_success 'pushing to local repo' '
2cb5a481
SR
68 (cd localclone &&
69 echo content >>file &&
70 git commit -a -m three &&
71 git push) &&
5cf5ade3 72 compare_refs localclone HEAD server HEAD
2cb5a481
SR
73'
74
7fb8e163 75# Generally, skip this test. It demonstrates a now-fixed race in
d0ac3ffd 76# git-remote-testpy, but is too slow to leave in for general use.
7fb8e163
PW
77: test_expect_success 'racily pushing to local repo' '
78 test_when_finished "rm -rf server2 localclone2" &&
d4a7ffaa 79 cp -R server server2 &&
d0ac3ffd 80 git clone "testpy::${PWD}/server2" localclone2 &&
7fb8e163
PW
81 (cd localclone2 &&
82 echo content >>file &&
83 git commit -a -m three &&
84 GIT_REMOTE_TESTGIT_SLEEPY=2 git push) &&
85 compare_refs localclone2 HEAD server2 HEAD
86'
87
760fec7d 88test_expect_success 'synch with changes from localclone' '
2cb5a481
SR
89 (cd clone &&
90 git pull)
91'
92
760fec7d 93test_expect_success 'pushing remote local repo' '
2cb5a481
SR
94 (cd clone &&
95 echo content >>file &&
96 git commit -a -m four &&
97 git push) &&
5cf5ade3 98 compare_refs clone HEAD server HEAD
2cb5a481
SR
99'
100
4e51ba23 101test_expect_success 'fetch new branch' '
c00dd33b
JK
102 (cd public &&
103 git checkout -b new &&
104 echo content >>file &&
105 git commit -a -m five &&
106 git push origin new
107 ) &&
108 (cd localclone &&
109 git fetch origin new
110 ) &&
111 compare_refs public HEAD localclone FETCH_HEAD
112'
113
9504bc9d 114test_expect_success 'fetch multiple branches' '
c00dd33b
JK
115 (cd localclone &&
116 git fetch
117 ) &&
118 compare_refs server master localclone refs/remotes/origin/master &&
119 compare_refs server new localclone refs/remotes/origin/new
120'
121
3ea7d094 122test_expect_success 'push when remote has extra refs' '
c00dd33b
JK
123 (cd clone &&
124 echo content >>file &&
125 git commit -a -m six &&
126 git push
127 ) &&
128 compare_refs clone master server master
129'
130
b4b87299 131test_expect_success 'push new branch by name' '
c00dd33b
JK
132 (cd clone &&
133 git checkout -b new-name &&
134 echo content >>file &&
135 git commit -a -m seven &&
136 git push origin new-name
137 ) &&
138 compare_refs clone HEAD server refs/heads/new-name
139'
140
141test_expect_failure 'push new branch with old:new refspec' '
142 (cd clone &&
143 git push origin new-name:new-refspec
144 ) &&
145 compare_refs clone HEAD server refs/heads/new-refspec
146'
147
6c323322
FC
148test_expect_success 'proper failure checks for fetching' '
149 (GIT_REMOTE_TESTGIT_FAILURE=1 &&
150 export GIT_REMOTE_TESTGIT_FAILURE &&
151 cd localclone &&
152 test_must_fail git fetch 2>&1 | \
153 grep "Error while running fast-import"
154 )
155'
156
157# We sleep to give fast-export a chance to catch the SIGPIPE
158test_expect_failure 'proper failure checks for pushing' '
159 (GIT_REMOTE_TESTGIT_FAILURE=1 &&
160 export GIT_REMOTE_TESTGIT_FAILURE &&
161 GIT_REMOTE_TESTGIT_SLEEPY=1 &&
162 export GIT_REMOTE_TESTGIT_SLEEPY &&
163 cd localclone &&
164 test_must_fail git push --all 2>&1 | \
165 grep "Error while running fast-export"
166 )
167'
168
2cb5a481 169test_done