Makes number of test retries a parameter.
This commit is contained in:
parent
c1b41d0fbf
commit
1d7ed8da40
14
test.py
14
test.py
@ -71,8 +71,6 @@ EA = "#" # Expand anonymous
|
|||||||
COMPL_KW = chr(24)+chr(14)
|
COMPL_KW = chr(24)+chr(14)
|
||||||
COMPL_ACCEPT = chr(25)
|
COMPL_ACCEPT = chr(25)
|
||||||
|
|
||||||
NUMBER_OF_RETRIES_FOR_EACH_TEST = 4
|
|
||||||
|
|
||||||
def running_on_windows():
|
def running_on_windows():
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
return "Does not work on Windows."
|
return "Does not work on Windows."
|
||||||
@ -275,7 +273,7 @@ class _VimTest(unittest.TestCase):
|
|||||||
if self.expected_error:
|
if self.expected_error:
|
||||||
self.assertRegexpMatches(self.output, self.expected_error)
|
self.assertRegexpMatches(self.output, self.expected_error)
|
||||||
return
|
return
|
||||||
for i in range(NUMBER_OF_RETRIES_FOR_EACH_TEST):
|
for i in range(self.retries):
|
||||||
if self.output != wanted:
|
if self.output != wanted:
|
||||||
# Redo this, but slower
|
# Redo this, but slower
|
||||||
self.sleeptime += 0.02
|
self.sleeptime += 0.02
|
||||||
@ -3202,7 +3200,7 @@ if __name__ == '__main__':
|
|||||||
p = optparse.OptionParser("%prog [OPTIONS] <test case names to run>")
|
p = optparse.OptionParser("%prog [OPTIONS] <test case names to run>")
|
||||||
|
|
||||||
p.set_defaults(session="vim", interrupt=False,
|
p.set_defaults(session="vim", interrupt=False,
|
||||||
verbose=False, interface="screen")
|
verbose=False, interface="screen", retries=4)
|
||||||
|
|
||||||
p.add_option("-v", "--verbose", dest="verbose", action="store_true",
|
p.add_option("-v", "--verbose", dest="verbose", action="store_true",
|
||||||
help="print name of tests as they are executed")
|
help="print name of tests as they are executed")
|
||||||
@ -3216,6 +3214,10 @@ if __name__ == '__main__':
|
|||||||
"to interactively test the snippet in vim. You must give " \
|
"to interactively test the snippet in vim. You must give " \
|
||||||
"exactly one test case on the cmdline. The test will always fail."
|
"exactly one test case on the cmdline. The test will always fail."
|
||||||
)
|
)
|
||||||
|
p.add_option("-r", "--retries", dest="retries", type=int,
|
||||||
|
help="How often should each test be retried before it is "
|
||||||
|
"considered failed. Works around flakyness in the terminal "
|
||||||
|
"multiplexer and race conditions in writing to the file system.")
|
||||||
|
|
||||||
o, args = p.parse_args()
|
o, args = p.parse_args()
|
||||||
if o.interface not in ("screen", "tmux"):
|
if o.interface not in ("screen", "tmux"):
|
||||||
@ -3237,8 +3239,6 @@ if __name__ == '__main__':
|
|||||||
elif options.interface == "tmux":
|
elif options.interface == "tmux":
|
||||||
vim = VimInterfaceTmux(options.session)
|
vim = VimInterfaceTmux(options.session)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vim.focus()
|
vim.focus()
|
||||||
|
|
||||||
vim.send(ESC)
|
vim.send(ESC)
|
||||||
@ -3280,13 +3280,13 @@ if __name__ == '__main__':
|
|||||||
for test in s:
|
for test in s:
|
||||||
test.vim = vim
|
test.vim = vim
|
||||||
test.interrupt = options.interrupt
|
test.interrupt = options.interrupt
|
||||||
|
test.retries = options.retries
|
||||||
if len(selected_tests):
|
if len(selected_tests):
|
||||||
id = test.id().split('.')[1]
|
id = test.id().split('.')[1]
|
||||||
if not any([ id.startswith(t) for t in selected_tests ]):
|
if not any([ id.startswith(t) for t in selected_tests ]):
|
||||||
continue
|
continue
|
||||||
suite.addTest(test)
|
suite.addTest(test)
|
||||||
|
|
||||||
|
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
v = 2
|
v = 2
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user