1818osp = os .path .dirname
1919
2020GIT_REPO = os .environ .get ("GIT_PYTHON_TEST_GIT_REPO_BASE" ,osp (osp (osp (osp (__file__ )))))
21+ GIT_DAEMON_PORT = os .environ .get ("GIT_PYTHON_TEST_GIT_DAEMON_PORT" ,"9418" )
2122
2223__all__ = (
2324'fixture_path' ,'fixture' ,'absolute_project_path' ,'StringProcessAdapter' ,
24- 'with_rw_repo' ,'with_rw_and_rw_remote_repo' ,'TestBase' ,'TestCase' ,'GIT_REPO'
25+ 'with_rw_repo' ,'with_rw_and_rw_remote_repo' ,'TestBase' ,'TestCase' ,'GIT_REPO' , 'GIT_DAEMON_PORT'
2526)
2627
2728#{ Routines
@@ -193,14 +194,15 @@ def remote_repo_creator(self):
193194# by the user, not by us
194195d_remote = Remote .create (rw_repo ,"daemon_origin" ,remote_repo_dir )
195196d_remote .fetch ()
196- remote_repo_url = "git://localhost%s " % remote_repo_dir
197+ remote_repo_url = "git://localhost:%s%s " % ( GIT_DAEMON_PORT , remote_repo_dir )
197198
198199d_remote .config_writer .set ('url' ,remote_repo_url )
199200
200201temp_dir = osp (_mktemp ())
201202# On windows, this will fail ... we deal with failures anyway and default to telling the user to do it
202203try :
203- gd = Git ().daemon (temp_dir ,enable = 'receive-pack' ,as_process = True )
204+ gd = Git ().daemon (temp_dir ,enable = 'receive-pack' ,listen = '127.0.0.1' ,port = GIT_DAEMON_PORT ,
205+ as_process = True )
204206# yes, I know ... fortunately, this is always going to work if sleep time is just large enough
205207time .sleep (0.5 )
206208except Exception :
@@ -223,6 +225,8 @@ def remote_repo_creator(self):
223225raise AssertionError (msg )
224226else :
225227msg = 'Please start a git-daemon to run this test, execute: git daemon --enable=receive-pack "%s"'
228+ msg += 'You can also run the daemon on a different port by passing --port=<port>'
229+ msg += 'and setting the environment variable GIT_PYTHON_TEST_GIT_DAEMON_PORT to <port>'
226230msg %= temp_dir
227231raise AssertionError (msg )
228232# END make assertion