[svn r63145] add support for "chdir"

--HG--
branch : trunk
This commit is contained in:
hpk 2009-03-20 16:52:39 +01:00
parent e383082b5b
commit 9cd41c91bd
2 changed files with 22 additions and 0 deletions

View File

@ -73,6 +73,17 @@ class TestMakegateway:
assert rinfo.cwd == py.std.os.getcwd() assert rinfo.cwd == py.std.os.getcwd()
assert rinfo.version_info[:2] == (2,6) 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): def test_ssh(self, specssh):
sshhost = specssh.ssh sshhost = specssh.ssh
gw = py.execnet.makegateway("ssh=%s" % sshhost) gw = py.execnet.makegateway("ssh=%s" % sshhost)

View File

@ -38,4 +38,15 @@ def makegateway(spec):
hostport = spec.socket.split(":") hostport = spec.socket.split(":")
gw = py.execnet.SocketGateway(*hostport) gw = py.execnet.SocketGateway(*hostport)
gw.spec = spec 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 return gw