[py-svn] r37455 - py/trunk/py/misc
hpk at codespeak.net
hpk at codespeak.net
Sun Jan 28 09:46:36 CET 2007
Author: hpk
Date: Sun Jan 28 09:46:34 2007
New Revision: 37455
Added:
py/trunk/py/misc/conftest-socketgatewayrun.py
Log:
added a sample conftest.py to run windows tests remotely,
note the module docstring.
Added: py/trunk/py/misc/conftest-socketgatewayrun.py
==============================================================================
--- (empty file)
+++ py/trunk/py/misc/conftest-socketgatewayrun.py Sun Jan 28 09:46:34 2007
@@ -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
More information about the pytest-commit
mailing list