summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostis Anagnostopoulos <ankostis@gmail.com>2016-09-27 00:09:20 +0200
committerKostis Anagnostopoulos <ankostis@gmail.com>2016-09-28 03:35:37 +0200
commitc572a8d95d8fa184eb58b15b7ff96d01ef1f9ec3 (patch)
tree2eccf43a7c2e162d2553d7255b8ec5b8983d4758
parent6a3c95b408162c78b9a4230bb4f7274a94d0add4 (diff)
downloadgitpython-c572a8d95d8fa184eb58b15b7ff96d01ef1f9ec3.tar.gz
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.
-rw-r--r--.appveyor.yml6
-rw-r--r--README.md12
-rw-r--r--git/test/lib/helper.py36
-rw-r--r--git/test/test_base.py1
-rw-r--r--git/test/test_remote.py4
5 files changed, 45 insertions, 14 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index fefd9478..7863d6d5 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -4,6 +4,7 @@ environment:
matrix:
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7"
+ GIT_PATH: "C:\\Program Files\\Git\\mingw64\\libexec\\git-core"
- PYTHON: "C:\\Miniconda"
PYTHON_VERSION: "2.7"
IS_CONDA: "yes"
@@ -12,12 +13,14 @@ environment:
- PYTHON: "C:\\Miniconda3-x64"
PYTHON_VERSION: "3.4"
IS_CONDA: "yes"
+ GIT_PATH: "C:\\Program Files\\Git\\mingw64\\libexec\\git-core"
- PYTHON: "C:\\Python34"
PYTHON_VERSION: "3.4"
GIT_PATH: "C:\\cygwin64\\bin"
- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5"
+ GIT_PATH: "C:\\Program Files\\Git\\mingw64\\libexec\\git-core"
- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5"
GIT_PATH: "C:\\cygwin64\\bin"
@@ -29,8 +32,7 @@ install:
#
- |
uname -a
- where git
- where python pip
+ where git git-daemon python pip
python --version
python -c "import struct; print(struct.calcsize('P') * 8)"
diff --git a/README.md b/README.md
index 12159a06..48b80bbd 100644
--- a/README.md
+++ b/README.md
@@ -61,9 +61,17 @@ as they are kept alive solely by their users, or not.
### RUNNING TESTS
-*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.
+*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.
-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:
+On *Windows*, make sure you have `git-daemon` in your PATH. For MINGW-git, the `git-daemon.exe`
+exists in `Git\mingw64\libexec\git-core\`; CYGWIN has no daemon, but should get along fine
+with MINGW's.
+
+The easiest way to run tests 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:
pip install tox
diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py
index d92d76e2..0a845a3f 100644
--- a/git/test/lib/helper.py
+++ b/git/test/lib/helper.py
@@ -140,6 +140,28 @@ def with_rw_repo(working_tree_ref, bare=False):
return argument_passer
+def launch_git_daemon(temp_dir, ip, port):
+ if is_win():
+ ## On MINGW-git, daemon exists in .\Git\mingw64\libexec\git-core\,
+ # but if invoked as 'git daemon', it detaches from parent `git` cmd,
+ # and then CANNOT DIE!
+ # So, invoke it as a single command.
+ ## Cygwin-git has no daemon.
+ #
+ daemon_cmd = ['git-daemon', temp_dir,
+ '--enable=receive-pack',
+ '--listen=%s' % ip,
+ '--port=%s' % port]
+ gd = Git().execute(daemon_cmd, as_process=True)
+ else:
+ gd = Git().daemon(temp_dir,
+ enable='receive-pack',
+ listen=ip,
+ port=port,
+ as_process=True)
+ return gd
+
+
def with_rw_and_rw_remote_repo(working_tree_ref):
"""
Same as with_rw_repo, but also provides a writable remote repository from which the
@@ -167,6 +189,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
assert isinstance(working_tree_ref, string_types), "Decorator requires ref name for working tree checkout"
def argument_passer(func):
+
def remote_repo_creator(self):
remote_repo_dir = _mktemp("remote_repo_%s" % func.__name__)
repo_dir = _mktemp("remote_clone_non_bare_repo")
@@ -202,9 +225,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
d_remote.config_writer.set('url', remote_repo_url)
temp_dir = osp(_mktemp())
- # On MINGW-git, daemon exists, in Cygwin-git, this will fail.
- gd = Git().daemon(temp_dir, enable='receive-pack', listen='127.0.0.1', port=GIT_DAEMON_PORT,
- as_process=True)
+ gd = launch_git_daemon(temp_dir, '127.0.0.1', GIT_DAEMON_PORT)
try:
# yes, I know ... fortunately, this is always going to work if sleep time is just large enough
time.sleep(0.5)
@@ -223,8 +244,10 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
rw_repo.git_dir, e)
if is_win():
msg = textwrap.dedent("""
- MINGW yet has problems with paths, CYGWIN additionally is missing `git-daemon`
- needed to run this test. Anyhow, try starting `git-daemon` manually:""")
+ MINGW yet has problems with paths, and `git-daemon.exe` must be in PATH
+ (look into .\Git\mingw64\libexec\git-core\);
+ CYGWIN has no daemon, but if one exists, it gets along fine (has also paths problems)
+ Anyhow, alternatively try starting `git-daemon` manually:""")
else:
msg = "Please try starting `git-daemon` manually:"
@@ -233,7 +256,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
You can also run the daemon on a different port by passing --port=<port>"
and setting the environment variable GIT_PYTHON_TEST_GIT_DAEMON_PORT to <port>
""" % temp_dir)
- raise AssertionError(msg)
+ from nose import SkipTest
+ raise SkipTest(msg) if is_win else AssertionError(msg)
# END make assertion
# END catch ls remote error
diff --git a/git/test/test_base.py b/git/test/test_base.py
index f139798b..cf92997f 100644
--- a/git/test/test_base.py
+++ b/git/test/test_base.py
@@ -112,7 +112,6 @@ class TestBase(TestBase):
assert not rw_repo.config_reader("repository").getboolean("core", "bare")
assert os.path.isdir(os.path.join(rw_repo.working_tree_dir, 'lib'))
- @skipIf(is_win(), "git-daemon proc stuck on Appveyor!")
@with_rw_and_rw_remote_repo('0.1.6')
def test_with_rw_remote_and_rw_repo(self, rw_repo, rw_remote_repo):
assert not rw_repo.config_reader("repository").getboolean("core", "bare")
diff --git a/git/test/test_remote.py b/git/test/test_remote.py
index 0060b5a6..2716d5b9 100644
--- a/git/test/test_remote.py
+++ b/git/test/test_remote.py
@@ -26,8 +26,7 @@ from git import (
GitCommandError
)
from git.util import IterableList
-from git.compat import string_types, is_win
-from unittest import skipIf
+from git.compat import string_types
import tempfile
import shutil
import os
@@ -100,7 +99,6 @@ class TestRemoteProgress(RemoteProgress):
assert self._num_progress_messages
-@skipIf(is_win(), "git-daemon proc stuck on Appveyor!")
class TestRemote(TestBase):
def tearDown(self):