提交 422fbd68 编写于 作者: L Lukáš Doktor

avocado.core.runner: Raise exception instead of sys.exit in runner

We have a nice mechanism to notify user about job failures, let's use
it instead of custom sys.exit().

Additionally add '\n' before the first message on exception, because
quite often there are already some characters written.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 04aa0c30
......@@ -519,11 +519,11 @@ class Job(object):
except exceptions.JobBaseException, details:
self.status = details.status
fail_class = details.__class__.__name__
self.view.notify(event='error', msg=('Avocado job failed: %s: %s' %
(fail_class, details)))
self.view.notify(event='error', msg=('\nAvocado job failed: %s: %s'
% (fail_class, details)))
return exit_codes.AVOCADO_JOB_FAIL
except exceptions.OptionValidationError, details:
self.view.notify(event='error', msg=str(details))
self.view.notify(event='error', msg='\n' + str(details))
return exit_codes.AVOCADO_JOB_FAIL
except Exception, details:
......@@ -532,7 +532,7 @@ class Job(object):
tb_info = traceback.format_exception(exc_type, exc_value,
exc_traceback.tb_next)
fail_class = details.__class__.__name__
self.view.notify(event='error', msg=('Avocado crashed: %s: %s' %
self.view.notify(event='error', msg=('\nAvocado crashed: %s: %s' %
(fail_class, details)))
for line in tb_info:
self.view.notify(event='minor', msg=line)
......
......@@ -155,11 +155,9 @@ class TestRunner(object):
early_state = queue.get()
if 'load_exception' in early_state:
self.job.view.notify(event='error',
msg='Avocado crashed during test load. '
'Some reports might have not been '
'generated. Aborting...')
sys.exit(exit_codes.AVOCADO_FAIL)
raise exceptions.TestError('Avocado crashed during test load. '
'Some reports might have not been '
'generated. Aborting...')
# At this point, the test is already initialized and we know
# for sure if there's a timeout set.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册