Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0387c57b76 | ||
|
|
bca7a5c35b | ||
|
|
689bf7262e | ||
|
|
5488b6d9a1 | ||
|
|
aed7a5a07e | ||
|
|
927e95176f | ||
|
|
8c6fea9895 | ||
|
|
1f6d410481 | ||
|
|
d5ff8b066a | ||
|
|
750ada16d1 | ||
|
|
c1f27bf87e | ||
|
|
c19f5e4bfd | ||
|
|
8a923ea2f4 | ||
|
|
e8ae2f9090 | ||
|
|
f946ab1835 | ||
|
|
1c2563d864 | ||
|
|
b04616419e | ||
|
|
722006f7f6 | ||
|
|
d9c5f18478 | ||
|
|
bd30e96ab0 | ||
|
|
eb09e22b62 | ||
|
|
319e247de5 | ||
|
|
1c712fe6a0 | ||
|
|
a6a4158b78 |
6
.hgtags
6
.hgtags
@@ -5,3 +5,9 @@ e6c4ce20db4bf65086ff55807a3c306cad7ca393 1.3
|
||||
e6c4ce20db4bf65086ff55807a3c306cad7ca393 1.3
|
||||
eaf8b1cb7c312883598677231be5bbeea3b5c127 1.3
|
||||
a423748bf17ee778a37853225210257699cad9c1 1.4
|
||||
cd44a941c833c098e4899fe3d42a96703754d0d5 1.5
|
||||
4815040bdad8f182a5487f57a9da385483836e75 1.6
|
||||
20875fed94e7f3dff50bdf762df91153b15ceca6 1.7
|
||||
20875fed94e7f3dff50bdf762df91153b15ceca6 1.7
|
||||
29c38e195526f5f0fdd651fb51f59d6efaaafbb0 1.7
|
||||
0d1c00018008433956aa7d93007bab6ea7de96e4 1.8
|
||||
|
||||
22
CHANGELOG
22
CHANGELOG
@@ -1,3 +1,25 @@
|
||||
1.8
|
||||
-------------------------
|
||||
|
||||
- fix pytest-issue93 - use the refined pytest-2.2.1 runtestprotocol
|
||||
interface to perform eager teardowns for test items.
|
||||
|
||||
1.7
|
||||
-------------------------
|
||||
|
||||
- fix incompatibilities with pytest-2.2.0 (allow multiple
|
||||
pytest_runtest_logreport reports for a test item)
|
||||
|
||||
1.6
|
||||
-------------------------
|
||||
|
||||
- terser collection reporting
|
||||
|
||||
- fix issue34 - distributed testing with -p plugin now works correctly
|
||||
|
||||
- fix race condition in looponfail mode where a concurrent file removal
|
||||
could cause a crash
|
||||
|
||||
1.5
|
||||
-------------------------
|
||||
|
||||
|
||||
@@ -3,8 +3,4 @@ include LICENSE
|
||||
include README.txt
|
||||
include setup.py
|
||||
graft testing
|
||||
exclude *.orig
|
||||
exclude *.rej
|
||||
recursive-exclude testing *.pyc *$py.class
|
||||
prune .svn
|
||||
prune .hg
|
||||
|
||||
6
setup.py
6
setup.py
@@ -2,7 +2,7 @@ from setuptools import setup
|
||||
|
||||
setup(
|
||||
name="pytest-xdist",
|
||||
version='1.5',
|
||||
version='1.8',
|
||||
description='py.test xdist plugin for distributed testing and loop-on-failing modes',
|
||||
long_description=open('README.txt').read(),
|
||||
license='GPLv2 or later',
|
||||
@@ -13,7 +13,7 @@ setup(
|
||||
packages = ['xdist'],
|
||||
entry_points = {'pytest11': ['xdist = xdist.plugin'],},
|
||||
zip_safe=False,
|
||||
install_requires = ['execnet>=1.0.8', 'pytest>1.9.9'],
|
||||
install_requires = ['execnet>=1.0.8', 'pytest>=2.2.1'],
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Intended Audience :: Developers',
|
||||
@@ -27,4 +27,4 @@ setup(
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 3',
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
@@ -314,7 +314,7 @@ def test_teardownfails_one_function(testdir):
|
||||
@py.test.mark.xfail
|
||||
def test_terminate_on_hangingnode(testdir):
|
||||
p = testdir.makeconftest("""
|
||||
def pytest__teardown_final(session):
|
||||
def pytest_sessionfinishes(session):
|
||||
if session.nodeid == "my": # running on slave
|
||||
import time
|
||||
time.sleep(3)
|
||||
@@ -407,5 +407,18 @@ def test_skipping(testdir):
|
||||
"*1 skipped*"
|
||||
])
|
||||
|
||||
|
||||
|
||||
def test_issue34_pluginloading_in_subprocess(testdir):
|
||||
testdir.tmpdir.join("plugin123.py").write(py.code.Source("""
|
||||
def pytest_namespace():
|
||||
return {'sample_variable': 'testing'}
|
||||
"""))
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
def test_hello():
|
||||
assert pytest.sample_variable == "testing"
|
||||
""")
|
||||
result = testdir.runpytest("-n1", "-p", "plugin123")
|
||||
assert result.ret == 0
|
||||
result.stdout.fnmatch_lines([
|
||||
"*1 passed*",
|
||||
])
|
||||
|
||||
@@ -16,13 +16,13 @@ def test_functional_boxed(testdir):
|
||||
class TestOptionEffects:
|
||||
def test_boxed_option_default(self, testdir):
|
||||
tmpdir = testdir.tmpdir.ensure("subdir", dir=1)
|
||||
config = testdir.reparseconfig()
|
||||
config = testdir.parseconfig()
|
||||
assert not config.option.boxed
|
||||
py.test.importorskip("execnet")
|
||||
config = testdir.reparseconfig(['-d', tmpdir])
|
||||
config = testdir.parseconfig('-d', tmpdir)
|
||||
assert not config.option.boxed
|
||||
|
||||
def test_is_not_boxed_by_default(self, testdir):
|
||||
config = testdir.reparseconfig([testdir.tmpdir])
|
||||
config = testdir.parseconfig(testdir.tmpdir)
|
||||
assert not config.option.boxed
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from xdist.dsession import DSession, LoadScheduling, EachScheduling
|
||||
from _pytest import session as outcome
|
||||
from _pytest import main as outcome
|
||||
import py
|
||||
import execnet
|
||||
|
||||
@@ -48,11 +48,11 @@ class TestEachScheduling:
|
||||
assert sched.node2collection[node1] == collection
|
||||
assert sched.node2collection[node2] == collection
|
||||
sched.init_distribute()
|
||||
assert not sched.tests_finished()
|
||||
assert sched.tests_finished()
|
||||
assert node1.sent == ['ALL']
|
||||
assert node2.sent == ['ALL']
|
||||
sched.remove_item(node1, collection[0])
|
||||
assert not sched.tests_finished()
|
||||
assert sched.tests_finished()
|
||||
sched.remove_item(node2, collection[0])
|
||||
assert sched.tests_finished()
|
||||
|
||||
@@ -66,7 +66,7 @@ class TestEachScheduling:
|
||||
assert sched.collection_is_completed
|
||||
assert sched.node2collection[node1] == collection
|
||||
sched.init_distribute()
|
||||
assert not sched.tests_finished()
|
||||
assert sched.tests_finished()
|
||||
crashitem = sched.remove_node(node1)
|
||||
assert crashitem
|
||||
assert sched.tests_finished()
|
||||
@@ -88,7 +88,7 @@ class TestLoadScheduling:
|
||||
assert sched.node2collection[node1] == collection
|
||||
assert sched.node2collection[node2] == collection
|
||||
sched.init_distribute()
|
||||
assert not sched.tests_finished()
|
||||
assert sched.tests_finished()
|
||||
assert len(node1.sent) == 1
|
||||
assert len(node2.sent) == 1
|
||||
x = sorted(node1.sent + node2.sent)
|
||||
@@ -109,6 +109,7 @@ class TestLoadScheduling:
|
||||
sched.addnode_collection(node1, col)
|
||||
sched.addnode_collection(node2, col)
|
||||
sched.init_distribute()
|
||||
#assert not sched.tests_finished()
|
||||
sent1 = node1.sent
|
||||
sent2 = node2.sent
|
||||
chunkitems = col[:sched.ITEM_CHUNKSIZE]
|
||||
|
||||
@@ -14,11 +14,11 @@ class TestStatRecorder:
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
tmp.ensure("new.py")
|
||||
p = tmp.ensure("new.py")
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
tmp.join("new.py").remove()
|
||||
p.remove()
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
@@ -36,6 +36,24 @@ class TestStatRecorder:
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
def test_filechange_deletion_race(self, tmpdir, monkeypatch):
|
||||
tmp = tmpdir
|
||||
sd = StatRecorder([tmp])
|
||||
changed = sd.check()
|
||||
assert not changed
|
||||
|
||||
p = tmp.ensure("new.py")
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
p.remove()
|
||||
# make check()'s visit() call return our just removed
|
||||
# path as if we were in a race condition
|
||||
monkeypatch.setattr(tmp, 'visit', lambda *args: [p])
|
||||
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
def test_pycremoval(self, tmpdir):
|
||||
tmp = tmpdir
|
||||
hello = tmp.ensure("hello.py")
|
||||
@@ -70,16 +88,14 @@ class TestRemoteControl:
|
||||
assert not failures
|
||||
|
||||
def test_failures_somewhere(self, testdir):
|
||||
item = testdir.getitem("def test_func(): assert 0\n")
|
||||
item = testdir.getitem("def test_func():\n assert 0\n")
|
||||
control = RemoteControl(item.config)
|
||||
control.setup()
|
||||
failures = control.runsession()
|
||||
assert failures
|
||||
control.setup()
|
||||
item.fspath.write("def test_func(): assert 1\n")
|
||||
pyc = item.fspath.new(ext=".pyc")
|
||||
if pyc.check():
|
||||
pyc.remove()
|
||||
item.fspath.write("def test_func():\n assert 1\n")
|
||||
removepyc(item.fspath)
|
||||
topdir, failures = control.runsession()[:2]
|
||||
assert not failures
|
||||
|
||||
@@ -97,9 +113,7 @@ class TestRemoteControl:
|
||||
def test_new():
|
||||
assert 0
|
||||
"""))
|
||||
pyc = modcol.fspath.new(ext=".pyc")
|
||||
if pyc.check():
|
||||
pyc.remove()
|
||||
removepyc(modcol.fspath)
|
||||
control.loop_once()
|
||||
assert not control.failures
|
||||
control.loop_once()
|
||||
@@ -234,4 +248,7 @@ def removepyc(path):
|
||||
pyc = path + "c"
|
||||
if pyc.check():
|
||||
pyc.remove()
|
||||
c = path.dirpath("__pycache__")
|
||||
if c.check():
|
||||
c.remove()
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ def test_remoteinitconfig(testdir):
|
||||
config1 = testdir.parseconfig()
|
||||
config2 = remote_initconfig(config1.option.__dict__, config1.args)
|
||||
assert config2.option.__dict__ == config1.option.__dict__
|
||||
py.test.raises(KeyError, 'config2.pluginmanager.getplugin("terminal")')
|
||||
assert config2.pluginmanager.getplugin("terminal") in (-1, None)
|
||||
|
||||
class TestReportSerialization:
|
||||
def test_itemreport_outcomes(self, testdir):
|
||||
@@ -80,7 +80,7 @@ class TestReportSerialization:
|
||||
py.test.xfail("hello")
|
||||
""")
|
||||
reports = reprec.getreports("pytest_runtest_logreport")
|
||||
assert len(reports) == 6
|
||||
assert len(reports) == 17 # with setup/teardown "passed" reports
|
||||
for rep in reports:
|
||||
d = serialize_report(rep)
|
||||
check_marshallable(d)
|
||||
@@ -138,13 +138,14 @@ class TestSlaveInteractor:
|
||||
ids = ev.kwargs['ids']
|
||||
assert len(ids) == 1
|
||||
slave.sendcommand("runtests", ids=ids)
|
||||
slave.sendcommand("shutdown")
|
||||
ev = slave.popevent("testreport") # setup
|
||||
ev = slave.popevent("testreport")
|
||||
assert ev.name == "testreport"
|
||||
rep = unserialize_report(ev.name, ev.kwargs['data'])
|
||||
assert rep.nodeid.endswith("::test_func")
|
||||
assert rep.passed
|
||||
assert rep.when == "call"
|
||||
slave.sendcommand("shutdown")
|
||||
ev = slave.popevent("slavefinished")
|
||||
assert 'slaveoutput' in ev.kwargs
|
||||
|
||||
@@ -194,16 +195,13 @@ class TestSlaveInteractor:
|
||||
ids = ev.kwargs['ids']
|
||||
assert len(ids) == 2
|
||||
slave.sendcommand("runtests_all", )
|
||||
ev = slave.popevent("testreport")
|
||||
assert ev.name == "testreport"
|
||||
rep = unserialize_report(ev.name, ev.kwargs['data'])
|
||||
assert rep.nodeid.endswith("::test_func")
|
||||
ev = slave.popevent("testreport")
|
||||
assert ev.name == "testreport"
|
||||
rep = unserialize_report(ev.name, ev.kwargs['data'])
|
||||
assert rep.nodeid.endswith("::test_func2")
|
||||
assert rep.passed
|
||||
slave.sendcommand("shutdown")
|
||||
slave.sendcommand("shutdown", )
|
||||
for func in "::test_func", "::test_func2":
|
||||
for i in range(3): # setup/call/teardown
|
||||
ev = slave.popevent("testreport")
|
||||
assert ev.name == "testreport"
|
||||
rep = unserialize_report(ev.name, ev.kwargs['data'])
|
||||
assert rep.nodeid.endswith(func)
|
||||
ev = slave.popevent("slavefinished")
|
||||
assert 'slaveoutput' in ev.kwargs
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ class TestNodeManager:
|
||||
@py.test.mark.xfail
|
||||
def test_rsync_roots_no_roots(self, testdir, mysetup):
|
||||
mysetup.source.ensure("dir1", "file1").write("hello")
|
||||
config = testdir.reparseconfig([source])
|
||||
config = testdir.parseconfig(source)
|
||||
nodemanager = NodeManager(config, ["popen//chdir=%s" % mysetup.dest])
|
||||
#assert nodemanager.config.topdir == source == config.topdir
|
||||
nodemanager.makegateways()
|
||||
@@ -179,7 +179,7 @@ class TestNodeManager:
|
||||
[pytest]
|
||||
rsyncdirs=dir1/dir2
|
||||
"""))
|
||||
config = testdir.reparseconfig([source])
|
||||
config = testdir.parseconfig(source)
|
||||
nodemanager = NodeManager(config, ["popen//chdir=%s" % dest])
|
||||
nodemanager.makegateways()
|
||||
nodemanager.rsync_roots()
|
||||
@@ -198,7 +198,7 @@ class TestNodeManager:
|
||||
rsyncdirs = dir1 dir5
|
||||
rsyncignore = dir1/dir2 dir5/dir6
|
||||
"""))
|
||||
config = testdir.reparseconfig([source])
|
||||
config = testdir.parseconfig(source)
|
||||
nodemanager = NodeManager(config, ["popen//chdir=%s" % dest])
|
||||
nodemanager.makegateways()
|
||||
nodemanager.rsync_roots()
|
||||
@@ -212,7 +212,7 @@ class TestNodeManager:
|
||||
specs = ["popen"] * 3
|
||||
source.join("conftest.py").write("rsyncdirs = ['a']")
|
||||
source.ensure('a', dir=1)
|
||||
config = testdir.reparseconfig([source])
|
||||
config = testdir.parseconfig(source)
|
||||
nodemanager = NodeManager(config, specs)
|
||||
nodemanager.makegateways()
|
||||
nodemanager.rsync_roots()
|
||||
|
||||
13
tox.ini
13
tox.ini
@@ -1,19 +1,24 @@
|
||||
[tox]
|
||||
envlist=py26,py31,py27,py25,py24
|
||||
indexserver=
|
||||
default = http://pypi.testrun.org
|
||||
testrun = http://pypi.testrun.org
|
||||
pypi = http://pypi.python.org/simple
|
||||
|
||||
[testenv]
|
||||
|
||||
changedir=testing
|
||||
deps=pytest
|
||||
deps=:testrun:pytest>=2.2.0.dev2
|
||||
commands= py.test --junitxml={envlogdir}/junit-{envname}.xml []
|
||||
|
||||
#[testenv:py31]
|
||||
#deps=:pypi:pytest # XXX needed because ClueRelease/pip broken
|
||||
#[testenv:py32]
|
||||
#deps=:pypi:pytest # XXX needed because ClueRelease/pip broken
|
||||
|
||||
[testenv:py26]
|
||||
deps=
|
||||
pytest
|
||||
:testrun:pytest
|
||||
:pypi:pexpect
|
||||
|
||||
[pytest]
|
||||
addopts = -rsfxX
|
||||
;; hello
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#
|
||||
__version__ = '1.5'
|
||||
__version__ = '1.8'
|
||||
|
||||
@@ -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,))
|
||||
|
||||
@@ -267,10 +264,11 @@ class DSession:
|
||||
|
||||
if self.sched.collection_is_completed:
|
||||
if self.terminal:
|
||||
self.trdist.ensure_show_status()
|
||||
self.terminal.write_line("")
|
||||
self.terminal.write_line("scheduling tests via %s" %(
|
||||
self.sched.__class__.__name__))
|
||||
|
||||
|
||||
self.sched.init_distribute()
|
||||
|
||||
def slave_logstart(self, node, nodeid, location):
|
||||
@@ -278,17 +276,14 @@ class DSession:
|
||||
nodeid=nodeid, location=location)
|
||||
|
||||
def slave_testreport(self, node, rep):
|
||||
if rep.when in ("setup", "call"):
|
||||
self.sched.remove_item(node, rep.nodeid)
|
||||
if not (rep.passed and rep.when != "call"):
|
||||
if rep.when in ("setup", "call"):
|
||||
self.sched.remove_item(node, rep.nodeid)
|
||||
#self.report_line("testreport %s: %s" %(rep.id, rep.status))
|
||||
rep.node = node
|
||||
self.config.hook.pytest_runtest_logreport(report=rep)
|
||||
self._handlefailures(rep)
|
||||
|
||||
def slave_teardownreport(self, node, rep):
|
||||
rep.node = node
|
||||
self.config.hook.pytest__teardown_final_logerror(report=rep)
|
||||
|
||||
def slave_collectreport(self, node, rep):
|
||||
#self.report_line("collectreport %s: %s" %(rep.id, rep.status))
|
||||
#rep.node = node
|
||||
@@ -327,13 +322,19 @@ class TerminalDistReporter:
|
||||
def write_line(self, msg):
|
||||
self.tr.write_line(msg)
|
||||
|
||||
def ensure_show_status(self):
|
||||
if not self.tr.hasmarkup:
|
||||
self.write_line(self.getstatus())
|
||||
|
||||
def setstatus(self, spec, status, show=True):
|
||||
self._status[spec.id] = status
|
||||
if show:
|
||||
parts = ["%s %s" %(spec.id, self._status[spec.id])
|
||||
for spec in self._specs]
|
||||
line = " / ".join(parts)
|
||||
self.rewrite(line)
|
||||
if show and self.tr.hasmarkup:
|
||||
self.rewrite(self.getstatus())
|
||||
|
||||
def getstatus(self):
|
||||
parts = ["%s %s" %(spec.id, self._status[spec.id])
|
||||
for spec in self._specs]
|
||||
return " / ".join(parts)
|
||||
|
||||
def rewrite(self, line, newline=False):
|
||||
pline = line + " " * max(self._lastlen-len(line), 0)
|
||||
@@ -347,8 +348,9 @@ class TerminalDistReporter:
|
||||
def pytest_xdist_setupnodes(self, specs):
|
||||
self._specs = specs
|
||||
for spec in specs:
|
||||
self.setstatus(spec, "initializing", show=False)
|
||||
self.setstatus(spec, "initializing", show=True)
|
||||
self.setstatus(spec, "I", show=False)
|
||||
self.setstatus(spec, "I", show=True)
|
||||
self.ensure_show_status()
|
||||
|
||||
def pytest_xdist_newgateway(self, gateway):
|
||||
if self.config.option.verbose > 0:
|
||||
@@ -357,7 +359,7 @@ class TerminalDistReporter:
|
||||
self.rewrite("[%s] %s Python %s cwd: %s" % (
|
||||
gateway.id, rinfo.platform, version, rinfo.cwd),
|
||||
newline=True)
|
||||
self.setstatus(gateway.spec, "collecting")
|
||||
self.setstatus(gateway.spec, "C")
|
||||
|
||||
def pytest_testnodeready(self, node):
|
||||
if self.config.option.verbose > 0:
|
||||
@@ -366,7 +368,7 @@ class TerminalDistReporter:
|
||||
d['id'],
|
||||
d['version'].replace('\n', ' -- '),)
|
||||
self.rewrite(infoline, newline=True)
|
||||
self.setstatus(node.gateway.spec, "ready")
|
||||
self.setstatus(node.gateway.spec, "ok")
|
||||
|
||||
def pytest_testnodedown(self, node, error):
|
||||
if not error:
|
||||
|
||||
@@ -120,9 +120,7 @@ def init_slave_session(channel, args, option_dict):
|
||||
|
||||
#fullwidth, hasmarkup = channel.receive()
|
||||
from _pytest.config import Config
|
||||
config = Config()
|
||||
config.option.__dict__.update(option_dict)
|
||||
config._preparse(list(args))
|
||||
config = Config.fromdictargs(option_dict, list(args))
|
||||
config.args = args
|
||||
from xdist.looponfail import SlaveFailSession
|
||||
SlaveFailSession(config, channel).main()
|
||||
@@ -203,14 +201,11 @@ class StatRecorder:
|
||||
newstat = {}
|
||||
for rootdir in self.rootdirlist:
|
||||
for path in rootdir.visit(self.fil, self.rec):
|
||||
oldstat = statcache.get(path, None)
|
||||
if oldstat is not None:
|
||||
del statcache[path]
|
||||
oldstat = statcache.pop(path, None)
|
||||
try:
|
||||
newstat[path] = curstat = path.stat()
|
||||
except py.error.ENOENT:
|
||||
if oldstat:
|
||||
del statcache[path]
|
||||
changed = True
|
||||
else:
|
||||
if oldstat:
|
||||
|
||||
@@ -26,10 +26,6 @@ class SlaveInteractor:
|
||||
for line in str(excrepr).split("\n"):
|
||||
self.log("IERROR> " + line)
|
||||
|
||||
def pytest__teardown_final_logerror(self, report):
|
||||
rep = serialize_report(report)
|
||||
self.sendevent("teardownreport", data=rep)
|
||||
|
||||
def pytest_sessionstart(self, session):
|
||||
self.session = session
|
||||
slaveinfo = getinfodict()
|
||||
@@ -46,18 +42,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
|
||||
|
||||
@@ -109,10 +113,8 @@ def getinfodict():
|
||||
|
||||
def remote_initconfig(option_dict, args):
|
||||
from _pytest.config import Config
|
||||
config = Config()
|
||||
config.pluginmanager.unregister(name="terminal")
|
||||
config._preparse(args, addopts=False)
|
||||
config.option.__dict__.update(option_dict)
|
||||
option_dict['plugins'].append("no:terminal")
|
||||
config = Config.fromdictargs(option_dict, args)
|
||||
config.option.looponfail = False
|
||||
config.option.usepdb = False
|
||||
config.option.dist = "no"
|
||||
@@ -120,7 +122,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()
|
||||
|
||||
@@ -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. """
|
||||
@@ -298,5 +301,3 @@ def unserialize_report(name, reportdict):
|
||||
return runner.TestReport(**d)
|
||||
elif name == "collectreport":
|
||||
return runner.CollectReport(**d)
|
||||
elif name == "teardownreport":
|
||||
return runner.TeardownErrorReport(**d)
|
||||
|
||||
Reference in New Issue
Block a user