[svn r37455] added a sample conftest.py to run windows tests remotely,
note the module docstring. --HG-- branch : trunk
This commit is contained in:
parent
37803778c9
commit
c736976568
|
@ -0,0 +1,58 @@
|
|||
"""
|
||||
|
||||
Put this file as 'conftest.py' somewhere upwards from py-trunk,
|
||||
modify the "socketserveradr" below to point to a windows/linux
|
||||
host running "py/execnet/script/loop_socketserver.py"
|
||||
and invoke e.g. from linux:
|
||||
|
||||
py.test --session=MySession some_path_to_what_you_want_to_test
|
||||
|
||||
This should ad-hoc distribute the running of tests to
|
||||
the remote machine (including rsyncing your WC).
|
||||
|
||||
"""
|
||||
import py
|
||||
from py.__.test.terminal.remote import RemoteTerminalSession
|
||||
|
||||
import os
|
||||
|
||||
class MyRSync(py.execnet.RSync):
|
||||
def filter(self, path):
|
||||
if path.endswith('.pyc') or path.endswith('~'):
|
||||
return False
|
||||
dir, base = os.path.split(path)
|
||||
# we may want to have revision info on the other side,
|
||||
# so let's not exclude .svn directories
|
||||
#if base == '.svn':
|
||||
# return False
|
||||
return True
|
||||
|
||||
class MySession(RemoteTerminalSession):
|
||||
socketserveradr = ('10.9.4.148', 8888)
|
||||
|
||||
def _initslavegateway(self):
|
||||
print "MASTER: initializing remote socket gateway"
|
||||
gw = py.execnet.SocketGateway(*self.socketserveradr)
|
||||
rsync = MyRSync(delete=True)
|
||||
channel = gw.remote_exec("""
|
||||
import os
|
||||
path = os.path.join(os.environ['HOMEPATH'], 'pytestcache')
|
||||
channel.send(path)
|
||||
""")
|
||||
remotetopdir = channel.receive()
|
||||
rsync.add_target(gw, remotetopdir)
|
||||
sendpath = py.path.local(py.__file__).dirpath().dirpath()
|
||||
rsync.send(sendpath)
|
||||
channel = gw.remote_exec("""
|
||||
import os, sys
|
||||
path = %r # os.path.abspath
|
||||
sys.path.insert(0, path)
|
||||
os.chdir(path)
|
||||
import py
|
||||
channel.send((path, py.__file__))
|
||||
""" % remotetopdir)
|
||||
topdir, remotepypath = channel.receive()
|
||||
assert topdir == remotetopdir, (topdir, remotetopdir)
|
||||
assert remotepypath.startswith(topdir), (remotepypath, topdir)
|
||||
#print "remote side has rsynced pythonpath ready: %r" %(topdir,)
|
||||
return gw, topdir
|
Loading…
Reference in New Issue