Skip to content

Commit c572a8d

Browse files
committed
Win, #519: FIX undead Git-daemon on Windows
+ On MINGW-git, daemon exists but if invoked as 'git daemon', DAEMON CANNOT DIE! + So, launch `git-daemon` on Apveyor, but - remote TCs fail due to paths problems. + Updated README instructions on Windows. + Restore disabled remote TCs on Windows. + Disable failures on daemon-tests only the last moment (raise SkipTest) so when ready, it will also pass.
1 parent 6a3c95b commit c572a8d

File tree

5 files changed

+45
-14
lines changed

5 files changed

+45
-14
lines changed

‎.appveyor.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ environment:
44
matrix:
55
- PYTHON: "C:\\Python27"
66
PYTHON_VERSION: "2.7"
7+
GIT_PATH: "C:\\Program Files\\Git\\mingw64\\libexec\\git-core"
78
- PYTHON: "C:\\Miniconda"
89
PYTHON_VERSION: "2.7"
910
IS_CONDA: "yes"
@@ -12,12 +13,14 @@ environment:
1213
- PYTHON: "C:\\Miniconda3-x64"
1314
PYTHON_VERSION: "3.4"
1415
IS_CONDA: "yes"
16+
GIT_PATH: "C:\\Program Files\\Git\\mingw64\\libexec\\git-core"
1517
- PYTHON: "C:\\Python34"
1618
PYTHON_VERSION: "3.4"
1719
GIT_PATH: "C:\\cygwin64\\bin"
1820

1921
- PYTHON: "C:\\Python35-x64"
2022
PYTHON_VERSION: "3.5"
23+
GIT_PATH: "C:\\Program Files\\Git\\mingw64\\libexec\\git-core"
2124
- PYTHON: "C:\\Python35-x64"
2225
PYTHON_VERSION: "3.5"
2326
GIT_PATH: "C:\\cygwin64\\bin"
@@ -29,8 +32,7 @@ install:
2932
#
3033
- |
3134
uname -a
32-
where git
33-
where python pip
35+
where git git-daemon python pip
3436
python --version
3537
python -c "import struct; print(struct.calcsize('P') * 8)"
3638

‎README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,17 @@ as they are kept alive solely by their users, or not.
6161

6262
### RUNNING TESTS
6363

64-
*Important*: Right after cloning this repository, please be sure to have executed the `./init-tests-after-clone.sh` script in the repository root. Otherwise you will encounter test failures.
64+
*Important*: Right after cloning this repository, please be sure to have executed
65+
the `./init-tests-after-clone.sh` script in the repository root. Otherwise
66+
you will encounter test failures.
6567

66-
The easiest way to run test is by using [tox](https://pypi.python.org/pypi/tox) a wrapper around virtualenv. It will take care of setting up environnements with the proper dependencies installed and execute test commands. To install it simply:
68+
On *Windows*, make sure you have `git-daemon` in your PATH. For MINGW-git, the `git-daemon.exe`
69+
exists in `Git\mingw64\libexec\git-core\`; CYGWIN has no daemon, but should get along fine
70+
with MINGW's.
71+
72+
The easiest way to run tests is by using [tox](https://pypi.python.org/pypi/tox)
73+
a wrapper around virtualenv. It will take care of setting up environnements with the proper
74+
dependencies installed and execute test commands. To install it simply:
6775

6876
pip install tox
6977

‎git/test/lib/helper.py

+30-6
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,28 @@ def repo_creator(self):
140140
return argument_passer
141141

142142

143+
def launch_git_daemon(temp_dir, ip, port):
144+
if is_win():
145+
## On MINGW-git, daemon exists in .\Git\mingw64\libexec\git-core\,
146+
# but if invoked as 'git daemon', it detaches from parent `git` cmd,
147+
# and then CANNOT DIE!
148+
# So, invoke it as a single command.
149+
## Cygwin-git has no daemon.
150+
#
151+
daemon_cmd = ['git-daemon', temp_dir,
152+
'--enable=receive-pack',
153+
'--listen=%s' % ip,
154+
'--port=%s' % port]
155+
gd = Git().execute(daemon_cmd, as_process=True)
156+
else:
157+
gd = Git().daemon(temp_dir,
158+
enable='receive-pack',
159+
listen=ip,
160+
port=port,
161+
as_process=True)
162+
return gd
163+
164+
143165
def with_rw_and_rw_remote_repo(working_tree_ref):
144166
"""
145167
Same as with_rw_repo, but also provides a writable remote repository from which the
@@ -167,6 +189,7 @@ def case(self, rw_repo, rw_remote_repo)
167189
assert isinstance(working_tree_ref, string_types), "Decorator requires ref name for working tree checkout"
168190

169191
def argument_passer(func):
192+
170193
def remote_repo_creator(self):
171194
remote_repo_dir = _mktemp("remote_repo_%s" % func.__name__)
172195
repo_dir = _mktemp("remote_clone_non_bare_repo")
@@ -202,9 +225,7 @@ def remote_repo_creator(self):
202225
d_remote.config_writer.set('url', remote_repo_url)
203226

204227
temp_dir = osp(_mktemp())
205-
# On MINGW-git, daemon exists, in Cygwin-git, this will fail.
206-
gd = Git().daemon(temp_dir, enable='receive-pack', listen='127.0.0.1', port=GIT_DAEMON_PORT,
207-
as_process=True)
228+
gd = launch_git_daemon(temp_dir, '127.0.0.1', GIT_DAEMON_PORT)
208229
try:
209230
# yes, I know ... fortunately, this is always going to work if sleep time is just large enough
210231
time.sleep(0.5)
@@ -223,8 +244,10 @@ def remote_repo_creator(self):
223244
rw_repo.git_dir, e)
224245
if is_win():
225246
msg = textwrap.dedent("""
226-
MINGW yet has problems with paths, CYGWIN additionally is missing `git-daemon`
227-
needed to run this test. Anyhow, try starting `git-daemon` manually:""")
247+
MINGW yet has problems with paths, and `git-daemon.exe` must be in PATH
248+
(look into .\Git\mingw64\libexec\git-core\);
249+
CYGWIN has no daemon, but if one exists, it gets along fine (has also paths problems)
250+
Anyhow, alternatively try starting `git-daemon` manually:""")
228251
else:
229252
msg = "Please try starting `git-daemon` manually:"
230253

@@ -233,7 +256,8 @@ def remote_repo_creator(self):
233256
You can also run the daemon on a different port by passing --port=<port>"
234257
and setting the environment variable GIT_PYTHON_TEST_GIT_DAEMON_PORT to <port>
235258
""" % temp_dir)
236-
raise AssertionError(msg)
259+
from nose import SkipTest
260+
raise SkipTest(msg) if is_win else AssertionError(msg)
237261
# END make assertion
238262
# END catch ls remote error
239263

‎git/test/test_base.py

-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def test_with_rw_repo(self, rw_repo):
112112
assert not rw_repo.config_reader("repository").getboolean("core", "bare")
113113
assert os.path.isdir(os.path.join(rw_repo.working_tree_dir, 'lib'))
114114

115-
@skipIf(is_win(), "git-daemon proc stuck on Appveyor!")
116115
@with_rw_and_rw_remote_repo('0.1.6')
117116
def test_with_rw_remote_and_rw_repo(self, rw_repo, rw_remote_repo):
118117
assert not rw_repo.config_reader("repository").getboolean("core", "bare")

‎git/test/test_remote.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
GitCommandError
2727
)
2828
from git.util import IterableList
29-
from git.compat import string_types, is_win
30-
from unittest import skipIf
29+
from git.compat import string_types
3130
import tempfile
3231
import shutil
3332
import os
@@ -100,7 +99,6 @@ def assert_received_message(self):
10099
assert self._num_progress_messages
101100

102101

103-
@skipIf(is_win(), "git-daemon proc stuck on Appveyor!")
104102
class TestRemote(TestBase):
105103

106104
def tearDown(self):

0 commit comments

Comments
 (0)