[py-svn] r31507 - in py/branch/distributed/py/test: rsession testing
hpk at codespeak.net
hpk at codespeak.net
Tue Aug 22 21:09:47 CEST 2006
Author: hpk
Date: Tue Aug 22 21:09:39 2006
New Revision: 31507
Modified:
py/branch/distributed/py/test/rsession/master.py
py/branch/distributed/py/test/rsession/rsession.py
py/branch/distributed/py/test/testing/test_collect.py
Log:
(fijal, hpk) hacking and cleaning up a bit to make RSession work a bit.
Modified: py/branch/distributed/py/test/rsession/master.py
==============================================================================
--- py/branch/distributed/py/test/rsession/master.py (original)
+++ py/branch/distributed/py/test/rsession/master.py Tue Aug 22 21:09:39 2006
@@ -41,8 +41,9 @@
_rsync = py.path.local.sysfind("rsync")
def bin_rsync(source, sshaddress, destpath):
- rsync.execute("-az", "--delete", "--exclude=.svn",
- source, sshaddress + ":" + str(destpath))
+ print "rsyncing", source, "to", sshaddress, destpath
+ _rsync.sysexec("-az", "--delete", "--exclude=.svn",
+ str(source), sshaddress + ":" + str(destpath))
def setup_slave(gateway, destpath):
from py.__.test.rsession import slave
Modified: py/branch/distributed/py/test/rsession/rsession.py
==============================================================================
--- py/branch/distributed/py/test/rsession/rsession.py (original)
+++ py/branch/distributed/py/test/rsession/rsession.py Tue Aug 22 21:09:39 2006
@@ -4,14 +4,6 @@
def __init__(self, config):
self.config = config
- def start(self, colitem):
- print "starting colitem", colitem
-
- def finish(self, colitem, outcome):
- print "finishing colitem", colitem, "outcome", outcome
-
-
-
class RSession(object):
"""
An RSession executes collectors/items through a runner.
@@ -19,110 +11,24 @@
"""
def __init__(self, config):
self.config = config
- self.report = Reporter(config)
+
+ def report(self, *whatever):
+ print whatever
def main(self, args):
""" main loop for running tests. """
- colitems = self._map2colitems(args)
- print "hello world"
- print colitems
- raise SystemExit, 1
- count = 0
- while colitems:
- colitem = colitems.pop()
- self.runtraced(colitem)
- if len(self.results) < count:
- time.sleep(0.1)
-
- def runtraced(self, colitem):
- outcome = None
- colitem.startcapture()
- try:
- self.report.predispatch(colitem)
- self.dispatch(colitem)
- self.report.postdispatch(colitem)
- try:
- try:
- outcome = self.run(colitem)
- except (KeyboardInterrupt, Exit):
- raise
- except colitem.Outcome, outcome:
- if outcome.excinfo is None:
- outcome.excinfo = py.code.ExceptionInfo()
- except:
- excinfo = py.code.ExceptionInfo()
- outcome = colitem.Failed(excinfo=excinfo)
- assert (outcome is None or
- isinstance(outcome, (list, colitem.Outcome)))
- finally:
- self.finish(colitem, outcome)
- if isinstance(outcome, colitem.Failed) and self.config.option.exitfirst:
- py.test.exit("exit on first problem configured.", item=colitem)
- finally:
- colitem.finishcapture()
-
- def run(self, colitem):
- if self.config.option.collectonly and isinstance(colitem, py.test.Item):
- return
- if isinstance(colitem, py.test.Item):
- self.skipbykeyword(colitem)
- res = colitem.run()
- if res is None:
- return py.test.Item.Passed()
- elif not isinstance(res, (list, tuple)):
- raise TypeError("%r.run() returned neither "
- "list, tuple nor None: %r" % (colitem, res))
- else:
- finish = self.startiteration(colitem, res)
- try:
- for name in res:
- obj = colitem.join(name)
- assert obj is not None
- self.runtraced(obj)
- finally:
- if finish:
- finish()
- return res
-
- def skipbykeyword(self, colitem):
- keyword = self.config.option.keyword
- if not keyword:
- return
- chain = colitem.listchain()
- for key in filter(None, keyword.split()):
- eor = key[:1] == '-'
- if eor:
- key = key[1:]
- if not (eor ^ self._matchonekeyword(key, chain)):
- py.test.skip("test not selected by keyword %r" %(keyword,))
-
- def _matchonekeyword(self, key, chain):
- for subitem in chain:
- if subitem.haskeyword(key):
- return True
- return False
-
-
- def _map2colitems(items):
- # first convert all path objects into collectors
- from py.__.test.collect import getfscollector
- colitems = []
- for item in items:
- if isinstance(item, (list, tuple)):
- colitems.extend(Session._map2colitems(item))
- elif not isinstance(item, py.test.collect.Collector):
- colitems.append(getfscollector(item))
- else:
- colitems.append(item)
- return colitems
- _map2colitems = staticmethod(_map2colitems)
-
-class Exit(Exception):
- """ for immediate program exits without tracebacks and reporter/summary. """
- def __init__(self, msg="unknown reason", item=None):
- self.msg = msg
- Exception.__init__(self, msg)
-
-def exit(msg, item=None):
- raise Exit(msg=msg, item=item)
+ from py.__.test.terminal.remote import getrootdir
+ from py.__.test.rsession.master import (
+ setup_slave, bin_rsync, MasterNode)
+ #colitems = self._map2colitems(args)
+ sshhosts = self.config.getinitialvalue("disthosts")
+ relpath = "pytestcache"
+ rootdir = getrootdir(args)
+ nodes = []
+ for host in sshhosts:
+ bin_rsync(rootdir, host, relpath)
+ gw = py.execnet.SshGateway(host)
+ ch = setup_slave(gw, relpath)
+ nodes.append(MasterNode(ch, self.report))
+ print "INITIALIZED, dying now ..."
Modified: py/branch/distributed/py/test/testing/test_collect.py
==============================================================================
--- py/branch/distributed/py/test/testing/test_collect.py (original)
+++ py/branch/distributed/py/test/testing/test_collect.py Tue Aug 22 21:09:39 2006
@@ -34,6 +34,8 @@
assert x.name == "filetest.py"
x = col1.getitembynames("/".join(l[1:]))
assert x.name == "filetest.py"
+ l2 = x.listnames()
+ assert len(l2) == 3
def test_finds_tests():
fn = datadir / 'filetest.py'
More information about the pytest-commit
mailing list