[svn r63201] allow to specify "3*" for host specs.
--HG-- branch : trunk
This commit is contained in:
parent
887a837600
commit
bda844b544
|
@ -27,7 +27,11 @@ To send tests to a python2.4 process, you may type::
|
|||
This will start a subprocess which is run with the "python2.4"
|
||||
Python interpreter, found in your system binary lookup path.
|
||||
|
||||
.. For convenience you may prepend ``3*`` to create three sub processes.
|
||||
If you prefix the --tx option like this::
|
||||
|
||||
py.test --tx 3*popen//python=python2.4
|
||||
|
||||
then three subprocesses would be created.
|
||||
|
||||
|
||||
Sending tests to remote SSH accounts
|
||||
|
|
|
@ -255,15 +255,20 @@ class Config(object):
|
|||
def getxspecs(self):
|
||||
config = self
|
||||
if config.option.numprocesses:
|
||||
xspec = ['popen'] * config.option.numprocesses
|
||||
xspeclist = ['popen'] * config.option.numprocesses
|
||||
else:
|
||||
xspec = config.option.xspec
|
||||
if not xspec:
|
||||
xspec = config.getvalue("xspec")
|
||||
if xspec is None:
|
||||
xspeclist = []
|
||||
for xspec in config.getvalue("tx"):
|
||||
i = xspec.find("*")
|
||||
try:
|
||||
num = int(xspec[:i])
|
||||
except ValueError:
|
||||
xspeclist.append(xspec)
|
||||
else:
|
||||
xspeclist.extend([xspec[i+1:]] * num)
|
||||
if not xspeclist:
|
||||
raise config.Error("MISSING test execution (tx) nodes: please specify --tx")
|
||||
#print "option value for xspecs", xspec
|
||||
return [py.execnet.XSpec(x) for x in xspec]
|
||||
return [py.execnet.XSpec(x) for x in xspeclist]
|
||||
|
||||
def getrsyncdirs(self):
|
||||
config = self
|
||||
|
|
|
@ -26,7 +26,7 @@ class TestAsyncFunctional:
|
|||
print "test_1: conftest.option.someopt", conftest.option.someopt
|
||||
assert conftest.option.someopt
|
||||
"""))
|
||||
result = testdir.runpytest('-n1', p1, '--someopt')
|
||||
result = testdir.runpytest('-d', '--tx=popen', p1, '--someopt')
|
||||
assert result.ret == 0
|
||||
extra = result.stdout.fnmatch_lines([
|
||||
"*1 passed*",
|
||||
|
|
|
@ -117,39 +117,3 @@ class TestNodeManager:
|
|||
ev = sorter.getfirstnamed("itemtestreport")
|
||||
assert ev.passed
|
||||
|
||||
class TestOptionsAndConfiguration:
|
||||
def test_getxspecs_numprocesses(self, testdir):
|
||||
config = testdir.parseconfig("-n3")
|
||||
xspecs = config.getxspecs()
|
||||
assert len(xspecs) == 3
|
||||
|
||||
def test_getxspecs(self, testdir):
|
||||
testdir.chdir()
|
||||
config = testdir.parseconfig("--tx=popen", "--tx", "ssh=xyz")
|
||||
xspecs = config.getxspecs()
|
||||
assert len(xspecs) == 2
|
||||
print xspecs
|
||||
assert xspecs[0].popen
|
||||
assert xspecs[1].ssh == "xyz"
|
||||
|
||||
def test_getconfigroots(self, testdir):
|
||||
config = testdir.parseconfig('--rsyncdir=' + str(testdir.tmpdir))
|
||||
roots = config.getrsyncdirs()
|
||||
assert len(roots) == 1 + 1
|
||||
assert testdir.tmpdir in roots
|
||||
|
||||
def test_getconfigroots_with_conftest(self, testdir):
|
||||
testdir.chdir()
|
||||
p = py.path.local()
|
||||
for bn in 'x y z'.split():
|
||||
p.mkdir(bn)
|
||||
testdir.makeconftest("""
|
||||
rsyncdirs= 'x',
|
||||
""")
|
||||
config = testdir.parseconfig(testdir.tmpdir, '--rsyncdir=y', '--rsyncdir=z')
|
||||
roots = config.getrsyncdirs()
|
||||
assert len(roots) == 3 + 1
|
||||
assert py.path.local('y') in roots
|
||||
assert py.path.local('z') in roots
|
||||
assert testdir.tmpdir.join('x') in roots
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ class DefaultPlugin:
|
|||
help="number of local test processes. conflicts with --dist.")
|
||||
group.addoption('--rsyncdir', action="append", default=[], metavar="dir1",
|
||||
help="add local directory for rsync to remote test nodes.")
|
||||
group._addoption('--tx', dest="xspec", action="append",
|
||||
group._addoption('--tx', dest="tx", action="append", default=[],
|
||||
help=("add a test environment, specified in XSpec syntax. examples: "
|
||||
"--tx popen//python=python2.5 --tx socket=192.168.1.102"))
|
||||
#group._addoption('--rest',
|
||||
|
|
|
@ -287,7 +287,7 @@ class TestPyTest:
|
|||
""",
|
||||
)
|
||||
testdir.makeconftest("""
|
||||
pytest_option_xspec = 'popen popen popen'.split()
|
||||
pytest_option_tx = 'popen popen popen'.split()
|
||||
""")
|
||||
result = testdir.runpytest(p1, '-d')
|
||||
result.stdout.fnmatch_lines([
|
||||
|
@ -319,7 +319,7 @@ class TestPyTest:
|
|||
os.kill(os.getpid(), 15)
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest(p1, '-d', '-n 3')
|
||||
result = testdir.runpytest(p1, '-d', '--tx=3*popen')
|
||||
result.stdout.fnmatch_lines([
|
||||
"*popen*Python*",
|
||||
"*popen*Python*",
|
||||
|
|
|
@ -218,6 +218,48 @@ class TestConfigApi_getcolitems:
|
|||
assert col.config is config
|
||||
|
||||
|
||||
class TestOptionsAndConfiguration:
|
||||
def test_getxspecs_numprocesses(self, testdir):
|
||||
config = testdir.parseconfig("-n3")
|
||||
xspecs = config.getxspecs()
|
||||
assert len(xspecs) == 3
|
||||
|
||||
def test_getxspecs(self, testdir):
|
||||
testdir.chdir()
|
||||
config = testdir.parseconfig("--tx=popen", "--tx", "ssh=xyz")
|
||||
xspecs = config.getxspecs()
|
||||
assert len(xspecs) == 2
|
||||
print xspecs
|
||||
assert xspecs[0].popen
|
||||
assert xspecs[1].ssh == "xyz"
|
||||
|
||||
def test_xspecs_multiplied(self, testdir):
|
||||
testdir.chdir()
|
||||
xspecs = testdir.parseconfig("--tx=3*popen",).getxspecs()
|
||||
assert len(xspecs) == 3
|
||||
assert xspecs[1].popen
|
||||
|
||||
def test_getrsyncdirs(self, testdir):
|
||||
config = testdir.parseconfig('--rsyncdir=' + str(testdir.tmpdir))
|
||||
roots = config.getrsyncdirs()
|
||||
assert len(roots) == 1 + 1
|
||||
assert testdir.tmpdir in roots
|
||||
|
||||
def test_getrsyncdirs_with_conftest(self, testdir):
|
||||
testdir.chdir()
|
||||
p = py.path.local()
|
||||
for bn in 'x y z'.split():
|
||||
p.mkdir(bn)
|
||||
testdir.makeconftest("""
|
||||
rsyncdirs= 'x',
|
||||
""")
|
||||
config = testdir.parseconfig(testdir.tmpdir, '--rsyncdir=y', '--rsyncdir=z')
|
||||
roots = config.getrsyncdirs()
|
||||
assert len(roots) == 3 + 1
|
||||
assert py.path.local('y') in roots
|
||||
assert py.path.local('z') in roots
|
||||
assert testdir.tmpdir.join('x') in roots
|
||||
|
||||
|
||||
|
||||
class TestOptionEffects:
|
||||
|
|
Loading…
Reference in New Issue