From b8ea732fb0a2d8561d395226b11fe554b74b0b96 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 18 Jan 2010 13:49:35 +0100 Subject: [PATCH] add CHANGELGOG, and make "-x" work harder to shut down immediately. --- CHANGELOG | 11 +++++++++++ setup.py | 2 +- testing/test_dsession.py | 5 +++-- xdist/dsession.py | 12 ++++++++++-- xdist/txnode.py | 7 +++++-- 5 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 CHANGELOG diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..c4afdec --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,11 @@ +1.0 +------------------------- + +- moved code out of py-1.1.1 into its own plugin +- use a new, faster and more sensible model to do load-balancing + of tests - now no magic "MAXITEMSPERHOST" is needed and load-testing + works effectively even with very few tests. +- cleaned up termination handling +- make -x cause hard killing of test nodes to decrease wait time + until the traceback shows up on first failure + diff --git a/setup.py b/setup.py index aeb49de..8f08fc0 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ setup( packages = ['xdist'], entry_points = {'pytest11': ['xdist = xdist.plugin'],}, zip_safe=False, - install_requires = ['execnet', 'py>=1.2.0'], + install_requires = ['execnet>=1.0.3', 'py>=1.2.0'], classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', diff --git a/testing/test_dsession.py b/testing/test_dsession.py index c8c698a..edab42f 100644 --- a/testing/test_dsession.py +++ b/testing/test_dsession.py @@ -266,9 +266,10 @@ class TestDSession: session.queueevent("pytest_runtest_logreport", report=ev2) # now call the loop loopstate = session._initloopstate(items) - session.loop_once(loopstate) + from xdist.dsession import ExitFirstInterrupt + py.test.raises(ExitFirstInterrupt, "session.loop_once(loopstate)") assert loopstate.testsfailed - assert loopstate.shuttingdown + #assert loopstate.shuttingdown def test_shuttingdown_filters(self, testdir): item = testdir.getitem("def test_func(): pass") diff --git a/xdist/dsession.py b/xdist/dsession.py index 4a516bf..fe46926 100644 --- a/xdist/dsession.py +++ b/xdist/dsession.py @@ -57,6 +57,9 @@ class LoopState(object): self.colitems[:] = items + self.colitems self.dowork = False # avoid busywait +class ExitFirstInterrupt(KeyboardInterrupt): + pass + class DSession(Session): """ Session drives the collection and running of tests @@ -129,6 +132,8 @@ class DSession(Session): # termination conditions if ((loopstate.testsfailed and self.config.option.exitfirst) or (not self.item2nodes and not colitems and not self.queue.qsize())): + if self.config.option.exitfirst: + raise ExitFirstInterrupt() self.triggershutdown() loopstate.shuttingdown = True elif not self.node2pending: @@ -174,8 +179,11 @@ class DSession(Session): break except KeyboardInterrupt: excinfo = py.code.ExceptionInfo() - self.config.hook.pytest_keyboard_interrupt(excinfo=excinfo) - exitstatus = outcome.EXIT_INTERRUPTED + if excinfo.errisinstance(ExitFirstInterrupt): + exitstatus = outcome.EXIT_TESTSFAILED + else: + self.config.hook.pytest_keyboard_interrupt(excinfo=excinfo) + exitstatus = outcome.EXIT_INTERRUPTED except: self.config.pluginmanager.notify_exception() exitstatus = outcome.EXIT_INTERNALERROR diff --git a/xdist/txnode.py b/xdist/txnode.py index 85cc350..a00a8d4 100644 --- a/xdist/txnode.py +++ b/xdist/txnode.py @@ -74,8 +74,11 @@ class TXNode(object): def sendlist(self, itemlist): self.channel.send(itemlist) - def shutdown(self): - self.channel.send(None) + def shutdown(self, kill=False): + if kill: + self.gateway.exit() + else: + self.channel.send(None) # setting up slave code def install_slave(gateway, config):