diff options
author | Benedikt Morbach <benedikt.morbach@googlemail.com> | 2015-04-21 13:45:02 +0200 |
---|---|---|
committer | Benedikt Morbach <benedikt.morbach@googlemail.com> | 2015-04-21 14:44:16 +0200 |
commit | c1cedc5c417ddf3c2a955514dcca6fe74913259b (patch) | |
tree | e22cf0e02dacafafc1f2c2972e19ffb1d83ddd89 /git/test/lib/helper.py | |
parent | bccdb483aaa7235b85a49f2c208ee1befd2706dd (diff) | |
download | gitpython-c1cedc5c417ddf3c2a955514dcca6fe74913259b.tar.gz |
test: make git-daemon port configurable via env
add a GIT_PYTHON_TEST_GIT_DAEMON_PORT to set a port other than 9418,
for example for when you already have a daemon running on that port.
Diffstat (limited to 'git/test/lib/helper.py')
-rw-r--r-- | git/test/lib/helper.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 77ab82ff..8be2881c 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -18,10 +18,11 @@ from git.compat import string_types 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 @@ -193,14 +194,15 @@ def with_rw_and_rw_remote_repo(working_tree_ref): # 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', listen='127.0.0.1', 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: @@ -223,6 +225,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref): 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 |