mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Fix failed tests re-run logic
This commit is contained in:
parent
d6d8db119b
commit
8b7105e1f9
25
noxfile.py
25
noxfile.py
@ -228,13 +228,6 @@ def _runtests(session, coverage, transport, cmd_args):
|
|||||||
session.run('python', os.path.join('tests', 'runtests.py'), *cmd_args)
|
session.run('python', os.path.join('tests', 'runtests.py'), *cmd_args)
|
||||||
except CommandFailed:
|
except CommandFailed:
|
||||||
names_file_path = os.path.join('artifacts', 'failed-tests.txt')
|
names_file_path = os.path.join('artifacts', 'failed-tests.txt')
|
||||||
if not os.path.exists(names_file_path):
|
|
||||||
# raise the original exception
|
|
||||||
raise
|
|
||||||
with open(names_file_path) as rfh:
|
|
||||||
if not rfh.read():
|
|
||||||
# raise the original exception
|
|
||||||
raise
|
|
||||||
session.log('Re-running failed tests if possible')
|
session.log('Re-running failed tests if possible')
|
||||||
session.install('xunitparser==1.3.3')
|
session.install('xunitparser==1.3.3')
|
||||||
session.run(
|
session.run(
|
||||||
@ -243,10 +236,22 @@ def _runtests(session, coverage, transport, cmd_args):
|
|||||||
names_file_path
|
names_file_path
|
||||||
)
|
)
|
||||||
if not os.path.exists(names_file_path):
|
if not os.path.exists(names_file_path):
|
||||||
session.error('No names file was generated to re-run tests')
|
session.log(
|
||||||
|
'Failed tests file(%s) was not found. Not rerunning failed tests.',
|
||||||
|
names_file_path
|
||||||
|
)
|
||||||
|
# raise the original exception
|
||||||
|
raise
|
||||||
with open(names_file_path) as rfh:
|
with open(names_file_path) as rfh:
|
||||||
failed_tests_count = len(rfh.read().splitlines())
|
contents = rfh.read().strip()
|
||||||
|
if not contents:
|
||||||
|
session.log(
|
||||||
|
'The failed tests file(%s) is empty. Not rerunning failed tests.',
|
||||||
|
names_file_path
|
||||||
|
)
|
||||||
|
# raise the original exception
|
||||||
|
raise
|
||||||
|
failed_tests_count = len(contents.splitlines())
|
||||||
if failed_tests_count > 500:
|
if failed_tests_count > 500:
|
||||||
# 500 test failures?! Something else must have gone wrong, don't even bother
|
# 500 test failures?! Something else must have gone wrong, don't even bother
|
||||||
session.error(
|
session.error(
|
||||||
|
Loading…
Reference in New Issue
Block a user