Skip to content

git-daemon test fixes #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions git/test/lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
osp = os.path.dirname

GIT_REPO = os.environ.get("GIT_PYTHON_TEST_GIT_REPO_BASE", osp(osp(osp(osp(__file__)))))
GIT_DAEMON_PORT = os.environ.get("GIT_PYTHON_TEST_GIT_DAEMON_PORT", "9418")

__all__ = (
'fixture_path', 'fixture', 'absolute_project_path', 'StringProcessAdapter',
'with_rw_repo', 'with_rw_and_rw_remote_repo', 'TestBase', 'TestCase', 'GIT_REPO'
'with_rw_repo', 'with_rw_and_rw_remote_repo', 'TestBase', 'TestCase', 'GIT_REPO', 'GIT_DAEMON_PORT'
)

#{ Routines
Expand Down Expand Up @@ -193,14 +194,15 @@ def remote_repo_creator(self):
# by the user, not by us
d_remote = Remote.create(rw_repo, "daemon_origin", remote_repo_dir)
d_remote.fetch()
remote_repo_url = "git://localhost%s" % remote_repo_dir
remote_repo_url = "git://localhost:%s%s" % (GIT_DAEMON_PORT, remote_repo_dir)

d_remote.config_writer.set('url', remote_repo_url)

temp_dir = osp(_mktemp())
# On windows, this will fail ... we deal with failures anyway and default to telling the user to do it
try:
gd = Git().daemon(temp_dir, enable='receive-pack', as_process=True)
gd = Git().daemon(temp_dir, enable='receive-pack', listen='127.0.0.1', port=GIT_DAEMON_PORT,
as_process=True)
# yes, I know ... fortunately, this is always going to work if sleep time is just large enough
time.sleep(0.5)
except Exception:
Expand All @@ -223,6 +225,8 @@ def remote_repo_creator(self):
raise AssertionError(msg)
else:
msg = 'Please start a git-daemon to run this test, execute: git daemon --enable=receive-pack "%s"'
msg += 'You can also run the daemon on a different port by passing --port=<port>'
msg += 'and setting the environment variable GIT_PYTHON_TEST_GIT_DAEMON_PORT to <port>'
msg %= temp_dir
raise AssertionError(msg)
# END make assertion
Expand Down
5 changes: 3 additions & 2 deletions git/test/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
TestBase,
with_rw_repo,
with_rw_and_rw_remote_repo,
fixture
fixture,
GIT_DAEMON_PORT
)
from git import (
RemoteProgress,
Expand Down Expand Up @@ -250,7 +251,7 @@ def get_info(res, remote, name):
# must clone with a local path for the repo implementation not to freak out
# as it wants local paths only ( which I can understand )
other_repo = remote_repo.clone(other_repo_dir, shared=False)
remote_repo_url = "git://localhost%s" % remote_repo.git_dir
remote_repo_url = "git://localhost:%s%s" % (GIT_DAEMON_PORT, remote_repo.git_dir)

# put origin to git-url
other_origin = other_repo.remotes.origin
Expand Down