From c736976568d30b7a2173d12218fb7bdc66c5692c Mon Sep 17 00:00:00 2001 From: hpk Date: Sun, 28 Jan 2007 09:46:34 +0100 Subject: [PATCH] [svn r37455] added a sample conftest.py to run windows tests remotely, note the module docstring. --HG-- branch : trunk --- py/misc/conftest-socketgatewayrun.py | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 py/misc/conftest-socketgatewayrun.py diff --git a/py/misc/conftest-socketgatewayrun.py b/py/misc/conftest-socketgatewayrun.py new file mode 100644 index 000000000..31b7b3e13 --- /dev/null +++ b/py/misc/conftest-socketgatewayrun.py @@ -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