[svn r63195] * fix rsyncdir usages all around

* rename looponfailing to looponfail

--HG--
branch : trunk
This commit is contained in:
hpk 2009-03-21 21:07:45 +01:00
parent 87f6f6b9f4
commit 422635ea47
9 changed files with 30 additions and 33 deletions

View File

@ -267,21 +267,18 @@ class Config(object):
def getrsyncdirs(self): def getrsyncdirs(self):
config = self config = self
roots = config.option.rsyncdirs roots = config.option.rsyncdir
if roots:
roots = [py.path.local(x) for x in roots.split(',')]
else:
roots = []
conftestroots = config.getconftest_pathlist("rsyncdirs") conftestroots = config.getconftest_pathlist("rsyncdirs")
if conftestroots: if conftestroots:
roots.extend(conftestroots) roots.extend(conftestroots)
pydir = py.path.local(py.__file__).dirpath() pydir = py.path.local(py.__file__).dirpath()
roots = [py.path.local(root) for root in roots]
for root in roots: for root in roots:
if not root.check(): if not root.check():
raise ValueError("rsyncdir doesn't exist: %r" %(root,)) raise config.Error("rsyncdir doesn't exist: %r" %(root,))
if pydir is not None and root.basename == "py": if pydir is not None and root.basename == "py":
if root != pydir: if root != pydir:
raise ValueError("root %r conflicts with current %r" %(root, pydir)) raise config.Error("root %r conflicts with imported %r" %(root, pydir))
pydir = None pydir = None
if pydir is not None: if pydir is not None:
roots.append(pydir) roots.append(pydir)

View File

@ -64,7 +64,7 @@ class TestAsyncFunctional:
subdir.ensure("__init__.py") subdir.ensure("__init__.py")
p = subdir.join("test_one.py") p = subdir.join("test_one.py")
p.write("def test_5(): assert not __file__.startswith(%r)" % str(p)) p.write("def test_5(): assert not __file__.startswith(%r)" % str(p))
result = testdir.runpytest("-d", "--rsyncdirs=%(subdir)s" % locals(), result = testdir.runpytest("-d", "--rsyncdir=%(subdir)s" % locals(),
"--tx=popen//chdir=%(dest)s" % locals(), p) "--tx=popen//chdir=%(dest)s" % locals(), p)
assert result.ret == 0 assert result.ret == 0
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([

View File

@ -36,7 +36,7 @@ class TestNodeManager:
dest.remove() dest.remove()
nodemanager = NodeManager(testdir.parseconfig( nodemanager = NodeManager(testdir.parseconfig(
"--tx", "popen//chdir=%s" % dest, "--tx", "popen//chdir=%s" % dest,
"--rsyncdirs", rsyncroot, "--rsyncdir", rsyncroot,
source, source,
)) ))
assert nodemanager.config.topdir == source assert nodemanager.config.topdir == source
@ -112,7 +112,7 @@ class TestNodeManager:
def test_one(): def test_one():
pass pass
""") """)
sorter = testdir.inline_run("-d", "--rsyncdirs=%s" % testdir.tmpdir, sorter = testdir.inline_run("-d", "--rsyncdir=%s" % testdir.tmpdir,
"--tx=%s" % specssh, testdir.tmpdir) "--tx=%s" % specssh, testdir.tmpdir)
ev = sorter.getfirstnamed("itemtestreport") ev = sorter.getfirstnamed("itemtestreport")
assert ev.passed assert ev.passed
@ -133,7 +133,7 @@ class TestOptionsAndConfiguration:
assert xspecs[1].ssh == "xyz" assert xspecs[1].ssh == "xyz"
def test_getconfigroots(self, testdir): def test_getconfigroots(self, testdir):
config = testdir.parseconfig('--rsyncdirs=' + str(testdir.tmpdir)) config = testdir.parseconfig('--rsyncdir=' + str(testdir.tmpdir))
roots = config.getrsyncdirs() roots = config.getrsyncdirs()
assert len(roots) == 1 + 1 assert len(roots) == 1 + 1
assert testdir.tmpdir in roots assert testdir.tmpdir in roots
@ -146,7 +146,7 @@ class TestOptionsAndConfiguration:
testdir.makeconftest(""" testdir.makeconftest("""
rsyncdirs= 'x', rsyncdirs= 'x',
""") """)
config = testdir.parseconfig(testdir.tmpdir, '--rsyncdirs=y,z') config = testdir.parseconfig(testdir.tmpdir, '--rsyncdir=y', '--rsyncdir=z')
roots = config.getrsyncdirs() roots = config.getrsyncdirs()
assert len(roots) == 3 + 1 assert len(roots) == 3 + 1
assert py.path.local('y') in roots assert py.path.local('y') in roots

View File

@ -115,7 +115,7 @@ def slave_runsession(channel, config, fullwidth, hasmarkup):
DEBUG("SLAVE: received configuration, using topdir:", config.topdir) DEBUG("SLAVE: received configuration, using topdir:", config.topdir)
#config.option.session = None #config.option.session = None
config.option.looponfailing = False config.option.looponfail = False
config.option.usepdb = False config.option.usepdb = False
trails = channel.receive() trails = channel.receive()
config.pytestplugins.do_configure(config) config.pytestplugins.do_configure(config)
@ -150,5 +150,5 @@ def slave_runsession(channel, config, fullwidth, hasmarkup):
DEBUG("SLAVE: starting session.main()") DEBUG("SLAVE: starting session.main()")
session.main(colitems) session.main(colitems)
ev = event.LooponfailingInfo(list(failreports), [config.topdir]) ev = event.LooponfailingInfo(list(failreports), [config.topdir])
session.bus.notify("looponfailinginfo", ev) session.bus.notify("looponfailinfo", ev)
channel.send([x.colitem._totrail() for x in failreports if x.failed]) channel.send([x.colitem._totrail() for x in failreports if x.failed])

View File

@ -46,7 +46,7 @@ class TestRemoteControl:
assert str(failures).find("test_new") != -1 assert str(failures).find("test_new") != -1
class TestLooponFailing: class TestLooponFailing:
def test_looponfailing_from_fail_to_ok(self, testdir): def test_looponfail_from_fail_to_ok(self, testdir):
modcol = testdir.getmodulecol(""" modcol = testdir.getmodulecol("""
def test_one(): def test_one():
x = 0 x = 0
@ -71,7 +71,7 @@ class TestLooponFailing:
session.loop_once(loopstate) session.loop_once(loopstate)
assert not loopstate.colitems assert not loopstate.colitems
def test_looponfailing_from_one_to_two_tests(self, testdir): def test_looponfail_from_one_to_two_tests(self, testdir):
modcol = testdir.getmodulecol(""" modcol = testdir.getmodulecol("""
def test_one(): def test_one():
assert 0 assert 0
@ -96,7 +96,7 @@ class TestLooponFailing:
session.loop_once(loopstate) session.loop_once(loopstate)
assert len(loopstate.colitems) == 1 assert len(loopstate.colitems) == 1
def test_looponfailing_removed_test(self, testdir): def test_looponfail_removed_test(self, testdir):
modcol = testdir.getmodulecol(""" modcol = testdir.getmodulecol("""
def test_one(): def test_one():
assert 0 assert 0

View File

@ -75,8 +75,8 @@ class DefaultPlugin:
help=("load the specified plugin after command line parsing. " help=("load the specified plugin after command line parsing. "
"Example: '-p hello' will trigger 'import pytest_hello' " "Example: '-p hello' will trigger 'import pytest_hello' "
"and instantiate 'HelloPlugin' from the module.")) "and instantiate 'HelloPlugin' from the module."))
group._addoption('-f', '--looponfailing', group._addoption('-f', '--looponfail',
action="store_true", dest="looponfailing", default=False, action="store_true", dest="looponfail", default=False,
help="run tests, loop on failing test set, until all pass. repeat forever.") help="run tests, loop on failing test set, until all pass. repeat forever.")
group = parser.addgroup("test process debugging") group = parser.addgroup("test process debugging")
@ -116,8 +116,8 @@ class DefaultPlugin:
def fixoptions(self, config): def fixoptions(self, config):
if config.getvalue("usepdb"): if config.getvalue("usepdb"):
if config.getvalue("looponfailing"): if config.getvalue("looponfail"):
raise config.Error("--pdb incompatible with --looponfailing.") raise config.Error("--pdb incompatible with --looponfail.")
if config.getvalue("dist"): if config.getvalue("dist"):
raise config.Error("--pdb incomptaible with distributed testing.") raise config.Error("--pdb incomptaible with distributed testing.")
@ -132,7 +132,7 @@ class DefaultPlugin:
from py.__.test.session import Session from py.__.test.session import Session
config.setsessionclass(Session) config.setsessionclass(Session)
else: else:
if val("looponfailing"): if val("looponfail"):
from py.__.test.looponfail.remote import LooponfailingSession from py.__.test.looponfail.remote import LooponfailingSession
config.setsessionclass(LooponfailingSession) config.setsessionclass(LooponfailingSession)
elif val("numprocesses") or val("dist"): elif val("numprocesses") or val("dist"):
@ -179,7 +179,7 @@ def test_conflict_options():
py.test.raises(config.Error, py.test.raises(config.Error,
"config.pytestplugins.do_configure(config)") "config.pytestplugins.do_configure(config)")
conflict_options = ( conflict_options = (
'--looponfailing --pdb', '--looponfail --pdb',
'--dist --pdb', '--dist --pdb',
) )
for spec in conflict_options: for spec in conflict_options:

View File

@ -209,7 +209,7 @@ class PytestPluginHooks:
def pyevent_rescheduleitems(self, event): def pyevent_rescheduleitems(self, event):
""" Items from a node that went down. """ """ Items from a node that went down. """
def pyevent_looponfailinginfo(self, event): def pyevent_looponfailinfo(self, event):
""" info for repeating failing tests. """ """ info for repeating failing tests. """
def pyevent_plugin_registered(self, plugin): def pyevent_plugin_registered(self, plugin):

View File

@ -223,7 +223,7 @@ class TerminalReporter:
self.summary_deselected() self.summary_deselected()
self.summary_stats() self.summary_stats()
def pyevent_looponfailinginfo(self, event): def pyevent_looponfailinfo(self, event):
if event.failreports: if event.failreports:
self.write_sep("#", "LOOPONFAILING", red=True) self.write_sep("#", "LOOPONFAILING", red=True)
for report in event.failreports: for report in event.failreports:
@ -483,7 +483,7 @@ class TestTerminal:
assert lines[1].endswith("xy.py .") assert lines[1].endswith("xy.py .")
assert lines[2] == "hello world" assert lines[2] == "hello world"
def test_looponfailingreport(self, testdir, linecomp): def test_looponfailreport(self, testdir, linecomp):
modcol = testdir.getmodulecol(""" modcol = testdir.getmodulecol("""
def test_fail(): def test_fail():
assert 0 assert 0
@ -492,10 +492,10 @@ class TestTerminal:
""") """)
rep = TerminalReporter(modcol.config, file=linecomp.stringio) rep = TerminalReporter(modcol.config, file=linecomp.stringio)
reports = [basic_run_report(x) for x in modcol.collect()] reports = [basic_run_report(x) for x in modcol.collect()]
rep.pyevent_looponfailinginfo(event.LooponfailingInfo(reports, [modcol.config.topdir])) rep.pyevent_looponfailinfo(event.LooponfailingInfo(reports, [modcol.config.topdir]))
linecomp.assert_contains_lines([ linecomp.assert_contains_lines([
"*test_looponfailingreport.py:2: assert 0", "*test_looponfailreport.py:2: assert 0",
"*test_looponfailingreport.py:4: ValueError*", "*test_looponfailreport.py:4: ValueError*",
"*waiting*", "*waiting*",
"*%s*" % (modcol.config.topdir), "*%s*" % (modcol.config.topdir),
]) ])

View File

@ -401,24 +401,24 @@ class TestInteractive:
if child.isalive(): if child.isalive():
child.wait() child.wait()
def test_simple_looponfailing_interaction(self, testdir): def test_simple_looponfail_interaction(self, testdir):
spawn = self.getspawn(testdir.tmpdir) spawn = self.getspawn(testdir.tmpdir)
p1 = testdir.makepyfile(""" p1 = testdir.makepyfile("""
def test_1(): def test_1():
assert 1 == 0 assert 1 == 0
""") """)
p1.setmtime(p1.mtime() - 50.0) p1.setmtime(p1.mtime() - 50.0)
child = spawn("%s %s --looponfailing %s" % (py.std.sys.executable, pytestpath, p1)) child = spawn("%s %s --looponfail %s" % (py.std.sys.executable, pytestpath, p1))
child.timeout = EXPECTTIMEOUT child.timeout = EXPECTTIMEOUT
child.expect("assert 1 == 0") child.expect("assert 1 == 0")
child.expect("test_simple_looponfailing_interaction.py:") child.expect("test_simple_looponfail_interaction.py:")
child.expect("1 failed") child.expect("1 failed")
child.expect("waiting for changes") child.expect("waiting for changes")
p1.write(py.code.Source(""" p1.write(py.code.Source("""
def test_1(): def test_1():
assert 1 == 1 assert 1 == 1
""")) """))
child.expect("MODIFIED.*test_simple_looponfailing_interaction.py", timeout=4.0) child.expect("MODIFIED.*test_simple_looponfail_interaction.py", timeout=4.0)
child.expect("1 passed", timeout=5.0) child.expect("1 passed", timeout=5.0)
child.kill(15) child.kill(15)