[py-svn] r51152 - in py/branch/event/py/test2: . rsession rsession/testing testing
hpk at codespeak.net
hpk at codespeak.net
Thu Jan 31 13:58:44 CET 2008
Author: hpk
Date: Thu Jan 31 13:58:41 2008
New Revision: 51152
Modified:
py/branch/event/py/test2/repevent.py
py/branch/event/py/test2/reporter.py
py/branch/event/py/test2/rsession/hostmanage.py
py/branch/event/py/test2/rsession/rsession.py
py/branch/event/py/test2/rsession/testing/test_rsession.py
py/branch/event/py/test2/session.py
py/branch/event/py/test2/testing/test_repevent.py
Log:
tweaking more things and tests to work with new event arch
Modified: py/branch/event/py/test2/repevent.py
==============================================================================
--- py/branch/event/py/test2/repevent.py (original)
+++ py/branch/event/py/test2/repevent.py Thu Jan 31 13:58:41 2008
@@ -17,9 +17,6 @@
for key, value in self.__dict__.items()]
return "<%s %s>" %(self.__class__.__name__, " ".join(l),)
- def is_failure(self):
- return False
-
class SendItem(ReportEvent):
def __init__(self, channel, item):
self.item = item
@@ -35,9 +32,6 @@
self.item = item
self.outcome = outcome
- def is_failure(self):
- return not (self.outcome.passed or self.outcome.skipped)
-
#class CallEvent(ReportEvent):
# def __init__(self, func, args, kwargs):
# self.func = func
@@ -100,8 +94,6 @@
self.excinfo = excinfo
self.item = item
- def is_failure(self):
- return True
class ItemStart(ReportEvent):
""" This class shows most of the start stuff, like directory, module, class
Modified: py/branch/event/py/test2/reporter.py
==============================================================================
--- py/branch/event/py/test2/reporter.py (original)
+++ py/branch/event/py/test2/reporter.py Thu Jan 31 13:58:41 2008
@@ -39,8 +39,8 @@
self.flag = False
def report(self, event):
- if event.is_failure():
- self.flag = True
+ #if event.is_failure():
+ # self.flag = True
self.reportfun(event)
__call__ = report
Modified: py/branch/event/py/test2/rsession/hostmanage.py
==============================================================================
--- py/branch/event/py/test2/rsession/hostmanage.py (original)
+++ py/branch/event/py/test2/rsession/hostmanage.py Thu Jan 31 13:58:41 2008
@@ -156,6 +156,7 @@
for host in self.hosts:
rsync.add_target_host(host, destrelpath)
rsync.send(raises=False)
+ self.config.hub.notify(repevent.RsyncFinished())
def setup_hosts(self):
self.init_rsync()
@@ -166,37 +167,35 @@
nodes.append(MasterNode(ch, self.config.hub.notify))
return nodes
- def teardown_hosts(self, channels, nodes,
- waiter=lambda : time.sleep(.1), exitfirst=False):
- for channel in channels:
- channel.send(None)
- # XXX
+ def teardown_hosts(self, nodes, timeout=1.0):
return
-
- clean = exitfirst
+ for node in nodes:
+ node.channel.send(None)
+ clean = False
while not clean:
clean = True
for node in nodes:
if node.pending:
clean = False
- waiter()
- self.teardown_gateways(channels)
+ # XXX magic waiting
+ py.std.time.sleep(0.1)
+ self.teardown_gateways(nodes)
def kill_channels(self, channels):
for channel in channels:
channel.send(42)
- def teardown_gateways(self, channels):
+ def teardown_gateways(self, nodes):
return
- self.config.hub.notify("tear down %r" %(channels,))
- for channel in channels:
+ self.config.hub.notify("teardown gateways %r" %(nodes,))
+ for node in nodes:
#try:
try:
- channel.waitclose(1.0)
+ node.channel.waitclose(1.0)
except IOError: # timeout
# force closing
- channel.close()
- channel.gateway.exit()
+ node.channel.close()
+ node.channel.gateway.exit()
def gethomedir():
import os
Modified: py/branch/event/py/test2/rsession/rsession.py
==============================================================================
--- py/branch/event/py/test2/rsession/rsession.py (original)
+++ py/branch/event/py/test2/rsession/rsession.py Thu Jan 31 13:58:41 2008
@@ -41,14 +41,12 @@
raise SystemExit
def main(self):
-
""" main loop for running tests. """
hm = HostManager(self.config)
hub = self.config.hub
hub.notify(repevent.TestStarted(hm.hosts, self.config, hm.roots))
try:
nodes = hm.setup_hosts()
- hub.notify(repevent.RsyncFinished())
try:
self.dispatch_tests(nodes)
except (KeyboardInterrupt, SystemExit):
@@ -60,8 +58,7 @@
raise
print "tearing down nodes"
- channels = [node.channel for node in nodes]
- hm.teardown_hosts(channels, nodes)
+ hm.teardown_hosts(nodes)
hub.notify(repevent.Nodes(nodes))
# XXX retval = reporter(repevent.TestFinished())
hub.notify(repevent.TestFinished())
Modified: py/branch/event/py/test2/rsession/testing/test_rsession.py
==============================================================================
--- py/branch/event/py/test2/rsession/testing/test_rsession.py (original)
+++ py/branch/event/py/test2/rsession/testing/test_rsession.py Thu Jan 31 13:58:41 2008
@@ -98,64 +98,33 @@
assert failevents[2].outcome.excinfo.typename == 'TypeError'
assert str(tb[0].path).find("executor") != -1
assert tb[0].source.find("execute") != -1
-
- def test_setup_teardown_ssh(self):
- hosts = [HostInfo('localhost:%s' % self.dest)]
- setup_events = []
- teardown_events = []
- tmpdir = self.source
- config = py.test2.config._reparse([tmpdir])
- hm = HostManager(config, hosts)
-
- config.hub.append(setup_events.append)
- nodes = hm.setup_hosts()
-
- config.hub.append(teardown_events.append)
- hm.teardown_hosts([node.channel for node in nodes], nodes)
-
- count_rsyn_calls = [i for i in setup_events
- if isinstance(i, repevent.HostRSyncing)]
- assert len(count_rsyn_calls) == len([i for i in hosts])
- count_ready_calls = [i for i in setup_events
- if isinstance(i, repevent.HostRSyncRootReady)]
- assert len(count_ready_calls) == len([i for i in hosts])
-
- # same for teardown events
- teardown_wait_starts = [i for i in teardown_events
- if isinstance(i, repevent.CallStart)]
- teardown_wait_ends = [i for i in teardown_events
- if isinstance(i, repevent.CallFinish)]
- assert len(teardown_wait_starts) == len(hosts)
- assert len(teardown_wait_ends) == len(hosts)
def test_setup_teardown_run_ssh(self):
hosts = [HostInfo('localhost:%s' % self.dest)]
- allevents = []
- self.config.hub.append(allevents.append)
+
+ queue = py.std.Queue.Queue()
+ self.config.hub.append(queue.put)
hm = HostManager(self.config, hosts=hosts)
nodes = hm.setup_hosts()
- itempass = self.getexample("pass")
- itemfail = self.getexample("fail")
- itemskip = self.getexample("skip")
- itemprint = self.getexample("print")
-
# actually run some tests
for node in nodes:
- node.send(itempass)
- node.send(itemfail)
- node.send(itemskip)
- node.send(itemprint)
-
- hm.teardown_hosts([node.channel for node in nodes], nodes)
-
- events = [i for i in allevents
- if isinstance(i, repevent.ReceivedItemOutcome)]
+ node.send(self.getexample("pass"))
+ node.send(self.getexample("fail"))
+ node.send(self.getexample("skip"))
+ node.send(self.getexample("print"))
+
+ events = []
+ while len(events) < 4 * len(nodes):
+ item = queue.get(timeout=0.5)
+ if isinstance(item, repevent.ReceivedItemOutcome):
+ events.append(item)
+ print "got all events", events
+ hm.teardown_hosts(nodes)
passed = [i for i in events
if i.outcome.passed]
skipped = [i for i in events
if i.outcome.skipped]
- for x in allevents: print x
assert len(passed) == 2 * len(nodes)
assert len(skipped) == len(nodes)
assert len(events) == 4 * len(nodes)
Modified: py/branch/event/py/test2/session.py
==============================================================================
--- py/branch/event/py/test2/session.py (original)
+++ py/branch/event/py/test2/session.py Thu Jan 31 13:58:41 2008
@@ -52,6 +52,7 @@
hub.notify(repevent.FailedTryiter(excinfo, next))
hub.notify(repevent.ItemFinish(next))
+
class AbstractSession(object):
""" An abstract session executes collectors/items through a runner.
"""
@@ -114,10 +115,12 @@
try:
item = itemgenerator.next()
outcome = self.run(item)
+ self.config.hub.notify(repevent.ReceivedItemOutcome(None, item, outcome))
if outcome is not None:
if not outcome.passed and not outcome.skipped:
failures.append((item, outcome))
- self.config.hub.notify(repevent.ReceivedItemOutcome(None, item, outcome))
+ if self.config.option.exitfirst:
+ raise StopIteration()
except StopIteration:
break
finally:
Modified: py/branch/event/py/test2/testing/test_repevent.py
==============================================================================
--- py/branch/event/py/test2/testing/test_repevent.py (original)
+++ py/branch/event/py/test2/testing/test_repevent.py Thu Jan 31 13:58:41 2008
@@ -14,7 +14,8 @@
if method.startswith("report_") and method != "report_unknown":
assert method[len('report_'):] in repevent.__dict__
-def test_repevent_failures():
+def XXXbrokentest_repevent_failures():
+ # probably this thing here is a bad idea
from py.__.test2.outcome import SerializableOutcome, ReprOutcome
assert not repevent.ReportEvent().is_failure()
More information about the py-svn
mailing list