adapt to new pytest changes, use new addini/getini methods for rsyncdirs / rsyncignore options
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
1.5a1
|
1.5a1
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
|
- adapt to pytest-2.0 changes, rsyncdirs and rsyncignore can now
|
||||||
|
only be specified in [pytest] sections of ini files, see "py.test -h"
|
||||||
|
for details.
|
||||||
- major internal refactoring to match the py-1.4 event refactoring
|
- major internal refactoring to match the py-1.4 event refactoring
|
||||||
- perform test collection always at slave side instead of at the master
|
- perform test collection always at slave side instead of at the master
|
||||||
- make python2/python3 bridging work, remove usage of pickling
|
- make python2/python3 bridging work, remove usage of pickling
|
||||||
|
|||||||
@@ -173,8 +173,9 @@ class TestNodeManager:
|
|||||||
source.ensure("dir1", "somefile", dir=1)
|
source.ensure("dir1", "somefile", dir=1)
|
||||||
dir2.ensure("hello")
|
dir2.ensure("hello")
|
||||||
source.ensure("bogusdir", "file")
|
source.ensure("bogusdir", "file")
|
||||||
source.join("conftest.py").write(py.code.Source("""
|
source.join("tox.ini").write(py.std.textwrap.dedent("""
|
||||||
rsyncdirs = ['dir1/dir2']
|
[pytest]
|
||||||
|
rsyncdirs=dir1/dir2
|
||||||
"""))
|
"""))
|
||||||
config = testdir.reparseconfig([source])
|
config = testdir.reparseconfig([source])
|
||||||
nodemanager = NodeManager(config, ["popen//chdir=%s" % dest])
|
nodemanager = NodeManager(config, ["popen//chdir=%s" % dest])
|
||||||
@@ -189,9 +190,10 @@ class TestNodeManager:
|
|||||||
dir5 = source.ensure("dir5", "dir6", "bogus")
|
dir5 = source.ensure("dir5", "dir6", "bogus")
|
||||||
dirf = source.ensure("dir5", "file")
|
dirf = source.ensure("dir5", "file")
|
||||||
dir2.ensure("hello")
|
dir2.ensure("hello")
|
||||||
source.join("conftest.py").write(py.code.Source("""
|
source.join("tox.ini").write(py.std.textwrap.dedent("""
|
||||||
rsyncdirs = ['dir1', 'dir5']
|
[pytest]
|
||||||
rsyncignore = ['dir1/dir2', 'dir5/dir6']
|
rsyncdirs = dir1 dir5
|
||||||
|
rsyncignore = dir1/dir2 dir5/dir6
|
||||||
"""))
|
"""))
|
||||||
config = testdir.reparseconfig([source])
|
config = testdir.reparseconfig([source])
|
||||||
nodemanager = NodeManager(config, ["popen//chdir=%s" % dest])
|
nodemanager = NodeManager(config, ["popen//chdir=%s" % dest])
|
||||||
|
|||||||
@@ -168,12 +168,12 @@ class DSession:
|
|||||||
self.terminal = None
|
self.terminal = None
|
||||||
|
|
||||||
def report_line(self, line):
|
def report_line(self, line):
|
||||||
if self.terminal:
|
if self.terminal and self.config.option.verbose >= 0:
|
||||||
self.terminal.write_line(line)
|
self.terminal.write_line(line)
|
||||||
|
|
||||||
def pytest_sessionstart(self, session, __multicall__):
|
def pytest_sessionstart(self, session, __multicall__):
|
||||||
#print "remaining multicall methods", __multicall__.methods
|
#print "remaining multicall methods", __multicall__.methods
|
||||||
if not self.config.getvalue("verbose"):
|
if self.config.option.verbose > 0:
|
||||||
self.report_line("instantiating gateways (use -v for details): %s" %
|
self.report_line("instantiating gateways (use -v for details): %s" %
|
||||||
",".join(self.config.option.tx))
|
",".join(self.config.option.tx))
|
||||||
self.nodemanager = NodeManager(self.config)
|
self.nodemanager = NodeManager(self.config)
|
||||||
@@ -183,11 +183,11 @@ class DSession:
|
|||||||
""" teardown any resources after a test run. """
|
""" teardown any resources after a test run. """
|
||||||
self.nodemanager.teardown_nodes()
|
self.nodemanager.teardown_nodes()
|
||||||
|
|
||||||
def pytest_perform_collection(self, __multicall__):
|
def pytest_collection(self, __multicall__):
|
||||||
# prohibit collection of test items in master process
|
# prohibit collection of test items in master process
|
||||||
__multicall__.methods[:] = []
|
__multicall__.methods[:] = []
|
||||||
|
|
||||||
def pytest_runtest_mainloop(self):
|
def pytest_runtestloop(self):
|
||||||
numnodes = len(self.nodemanager.gwmanager.specs)
|
numnodes = len(self.nodemanager.gwmanager.specs)
|
||||||
dist = self.config.getvalue("dist")
|
dist = self.config.getvalue("dist")
|
||||||
if dist == "load":
|
if dist == "load":
|
||||||
@@ -316,13 +316,13 @@ class TerminalDistReporter:
|
|||||||
|
|
||||||
def pytest_gwmanage_newgateway(self, gateway):
|
def pytest_gwmanage_newgateway(self, gateway):
|
||||||
rinfo = gateway._rinfo()
|
rinfo = gateway._rinfo()
|
||||||
if self.config.getvalue("verbose"):
|
if self.config.option.verbose >= 0:
|
||||||
version = "%s.%s.%s" %rinfo.version_info[:3]
|
version = "%s.%s.%s" %rinfo.version_info[:3]
|
||||||
self.write_line("[%s] %s Python %s cwd: %s" % (
|
self.write_line("[%s] %s Python %s cwd: %s" % (
|
||||||
gateway.id, rinfo.platform, version, rinfo.cwd))
|
gateway.id, rinfo.platform, version, rinfo.cwd))
|
||||||
|
|
||||||
def pytest_testnodeready(self, node):
|
def pytest_testnodeready(self, node):
|
||||||
if self.config.getvalue("verbose"):
|
if self.config.option.verbose >= 0:
|
||||||
d = node.slaveinfo
|
d = node.slaveinfo
|
||||||
infoline = "[%s] Python %s" %(
|
infoline = "[%s] Python %s" %(
|
||||||
d['id'],
|
d['id'],
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class SlaveFailSession:
|
|||||||
if self.config.option.debug:
|
if self.config.option.debug:
|
||||||
print(" ".join(map(str, args)))
|
print(" ".join(map(str, args)))
|
||||||
|
|
||||||
def pytest_perform_collection(self, session):
|
def pytest_collection(self, session):
|
||||||
self.session = session
|
self.session = session
|
||||||
self.collection = session.collection
|
self.collection = session.collection
|
||||||
self.topdir, self.trails = self.current_command
|
self.topdir, self.trails = self.current_command
|
||||||
|
|||||||
@@ -126,17 +126,18 @@ put options values in a ``conftest.py`` file like this::
|
|||||||
Any commandline ``--tx`` specifictions will add to the list of
|
Any commandline ``--tx`` specifictions will add to the list of
|
||||||
available execution environments.
|
available execution environments.
|
||||||
|
|
||||||
Specifying "rsync" dirs in a conftest.py
|
Specifying "rsync" dirs in a setup.cfg|tox.ini
|
||||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
In your ``mypkg/conftest.py`` you may specify directories to synchronise
|
In a ``tox.ini`` or ``setup.cfg`` file in your root project directory
|
||||||
or to exclude::
|
you may specify directories to include or to exclude in synchronisation::
|
||||||
|
|
||||||
rsyncdirs = ['.', '../plugins']
|
[pytest]
|
||||||
rsyncignore = ['_cache']
|
rsyncdirs = . mypkg helperpkg
|
||||||
|
rsyncignore = .hg
|
||||||
|
|
||||||
These directory specifications are relative to the directory
|
These directory specifications are relative to the directory
|
||||||
where the ``conftest.py`` is found.
|
where the configuration file was found.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -173,6 +174,11 @@ def pytest_addoption(parser):
|
|||||||
group.addoption('--rsyncdir', action="append", default=[], metavar="dir1",
|
group.addoption('--rsyncdir', action="append", default=[], metavar="dir1",
|
||||||
help="add directory for rsyncing to remote tx nodes.")
|
help="add directory for rsyncing to remote tx nodes.")
|
||||||
|
|
||||||
|
parser.addini('rsyncdirs', 'list of (relative) paths to be rsynced for'
|
||||||
|
' remote distributed testing.', type="pathlist")
|
||||||
|
parser.addini('rsyncignore', 'list of (relative) paths to be ignored '
|
||||||
|
'for rsyncing.', type="pathlist")
|
||||||
|
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
# distributed testing hooks
|
# distributed testing hooks
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ class SlaveInteractor:
|
|||||||
self.sendevent("slavefinished", slaveoutput=self.config.slaveoutput)
|
self.sendevent("slavefinished", slaveoutput=self.config.slaveoutput)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def pytest_perform_collection(self, session):
|
def pytest_collection(self, session):
|
||||||
self.sendevent("collectionstart")
|
self.sendevent("collectionstart")
|
||||||
|
|
||||||
def pytest_runtest_mainloop(self, session):
|
def pytest_runtestloop(self, session):
|
||||||
self.log("entering main loop")
|
self.log("entering main loop")
|
||||||
while 1:
|
while 1:
|
||||||
name, kwargs = self.channel.receive()
|
name, kwargs = self.channel.receive()
|
||||||
@@ -62,7 +62,7 @@ class SlaveInteractor:
|
|||||||
break
|
break
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def pytest_log_finishcollection(self, collection):
|
def pytest_collection_finish(self, collection):
|
||||||
ids = [collection.getid(item) for item in collection.items]
|
ids = [collection.getid(item) for item in collection.items]
|
||||||
self.sendevent("collectionfinish",
|
self.sendevent("collectionfinish",
|
||||||
topdir=str(collection.topdir),
|
topdir=str(collection.topdir),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import py
|
import py, pytest
|
||||||
import sys, os
|
import sys, os
|
||||||
import execnet
|
import execnet
|
||||||
import xdist.remote
|
import xdist.remote
|
||||||
@@ -18,7 +18,7 @@ class NodeManager(object):
|
|||||||
self.config.hook.pytest_trace(category="nodemanage", msg=msg)
|
self.config.hook.pytest_trace(category="nodemanage", msg=msg)
|
||||||
|
|
||||||
def config_getignores(self):
|
def config_getignores(self):
|
||||||
return self.config.getconftest_pathlist("rsyncignore")
|
return self.config.getini("rsyncignore")
|
||||||
|
|
||||||
def rsync_roots(self):
|
def rsync_roots(self):
|
||||||
""" make sure that all remote gateways
|
""" make sure that all remote gateways
|
||||||
@@ -78,7 +78,7 @@ class NodeManager(object):
|
|||||||
else:
|
else:
|
||||||
xspeclist.extend([xspec[i+1:]] * num)
|
xspeclist.extend([xspec[i+1:]] * num)
|
||||||
if not xspeclist:
|
if not xspeclist:
|
||||||
raise config.Error(
|
raise pytest.UsageError(
|
||||||
"MISSING test execution (tx) nodes: please specify --tx")
|
"MISSING test execution (tx) nodes: please specify --tx")
|
||||||
return [execnet.XSpec(x) for x in xspeclist]
|
return [execnet.XSpec(x) for x in xspeclist]
|
||||||
|
|
||||||
@@ -86,14 +86,14 @@ class NodeManager(object):
|
|||||||
config = self.config
|
config = self.config
|
||||||
candidates = [py._pydir]
|
candidates = [py._pydir]
|
||||||
candidates += config.option.rsyncdir
|
candidates += config.option.rsyncdir
|
||||||
conftestroots = config.getconftest_pathlist("rsyncdirs")
|
conftestroots = config.getini("rsyncdirs")
|
||||||
if conftestroots:
|
if conftestroots:
|
||||||
candidates.extend(conftestroots)
|
candidates.extend(conftestroots)
|
||||||
roots = []
|
roots = []
|
||||||
for root in candidates:
|
for root in candidates:
|
||||||
root = py.path.local(root).realpath()
|
root = py.path.local(root).realpath()
|
||||||
if not root.check():
|
if not root.check():
|
||||||
raise config.Error("rsyncdir doesn't exist: %r" %(root,))
|
raise pytest.UsageError("rsyncdir doesn't exist: %r" %(root,))
|
||||||
if root not in roots:
|
if root not in roots:
|
||||||
roots.append(root)
|
roots.append(root)
|
||||||
return roots
|
return roots
|
||||||
|
|||||||
Reference in New Issue
Block a user