diff --git a/py/execnet/testing/test_xspec.py b/py/execnet/testing/test_xspec.py index aa5672847..56b31a1f9 100644 --- a/py/execnet/testing/test_xspec.py +++ b/py/execnet/testing/test_xspec.py @@ -73,6 +73,17 @@ class TestMakegateway: assert rinfo.cwd == py.std.os.getcwd() assert rinfo.version_info[:2] == (2,6) + def test_popen_chdir_absolute(self, testdir): + gw = py.execnet.makegateway("popen//chdir=%s" % testdir.tmpdir) + rinfo = gw._rinfo() + assert rinfo.cwd == str(testdir.tmpdir) + + def test_popen_chdir_newsub(self, testdir): + testdir.chdir() + gw = py.execnet.makegateway("popen//chdir=hello") + rinfo = gw._rinfo() + assert rinfo.cwd == str(testdir.tmpdir.join("hello")) + def test_ssh(self, specssh): sshhost = specssh.ssh gw = py.execnet.makegateway("ssh=%s" % sshhost) diff --git a/py/execnet/xspec.py b/py/execnet/xspec.py index edd095c92..676da1e32 100644 --- a/py/execnet/xspec.py +++ b/py/execnet/xspec.py @@ -38,4 +38,15 @@ def makegateway(spec): hostport = spec.socket.split(":") gw = py.execnet.SocketGateway(*hostport) gw.spec = spec + # XXX events + if spec.chdir: + gw.remote_exec(""" + import os + path = %r + try: + os.chdir(path) + except OSError: + os.mkdir(path) + os.chdir(path) + """ % spec.chdir).waitclose() return gw