fix issue 93 of pytest - avoid delayed teardowns

This commit is contained in:
holger krekel
2011-12-02 21:03:29 +00:00
parent d5ff8b066a
commit 1f6d410481
9 changed files with 40 additions and 24 deletions

View File

@@ -1,2 +1,2 @@
#
__version__ = '1.7'
__version__ = '1.8.dev1'

View File

@@ -24,9 +24,6 @@ class EachScheduling:
def tests_finished(self):
if not self.collection_is_completed:
return False
for items in self.node2pending.values():
if items:
return False
return True
def addnode_collection(self, node, collection):
@@ -79,9 +76,9 @@ class LoadScheduling:
def tests_finished(self):
if not self.collection_is_completed or self.pending:
return False
for items in self.node2pending.values():
if items:
return False
#for items in self.node2pending.values():
# if items:
# return False
return True
def addnode_collection(self, node, collection):
@@ -107,7 +104,7 @@ class LoadScheduling:
pending.append(item)
self.item2nodes.setdefault(item, []).append(node)
node.send_runtest(item)
#self.log("items waiting for node: %d" %(len(self.pending)))
self.log("items waiting for node: %d" %(len(self.pending)))
#self.log("item2pending still executing: %s" %(self.item2nodes,))
#self.log("node2pending: %s" %(self.node2pending,))

View File

@@ -46,18 +46,26 @@ class SlaveInteractor:
def pytest_runtestloop(self, session):
self.log("entering main loop")
torun = []
while 1:
name, kwargs = self.channel.receive()
self.log("received command %s(**%s)" % (name, kwargs))
if name == "runtests":
ids = kwargs['ids']
for nodeid in ids:
item = self._id2item[nodeid]
self.config.hook.pytest_runtest_protocol(item=item)
torun.append(self._id2item[nodeid])
elif name == "runtests_all":
for item in session.items:
self.config.hook.pytest_runtest_protocol(item=item)
elif name == "shutdown":
torun.extend(session.items)
self.log("items to run: %s" %(len(torun)))
while len(torun) >= 2:
item = torun.pop(0)
nextitem = torun[0]
self.config.hook.pytest_runtest_protocol(item=item,
nextitem=nextitem)
if name == "shutdown":
while torun:
self.config.hook.pytest_runtest_protocol(
item=torun.pop(0), nextitem=None)
break
return True
@@ -118,7 +126,7 @@ def remote_initconfig(option_dict, args):
config.option.numprocesses = None
config.args = args
return config
if __name__ == '__channelexec__':
slaveinput,args,option_dict = channel.receive()

View File

@@ -183,7 +183,7 @@ def make_reltoroot(roots, args):
raise ValueError("arg %s not relative to an rsync root" % (arg,))
l.append(splitcode.join(parts))
return l
class SlaveController(object):
ENDMARK = -1
@@ -237,8 +237,11 @@ class SlaveController(object):
self.sendcommand("runtests_all",)
def shutdown(self):
if not self._down and not self.channel.isclosed():
self.sendcommand("shutdown")
if not self._down:
try:
self.sendcommand("shutdown")
except IOError:
pass
def sendcommand(self, name, **kwargs):
""" send a named parametrized command to the other side. """