Bug 1622637 - Fix exception reraising in mozrunner r=gbrown

Differential Revision: https://phabricator.services.mozilla.com/D66895

--HG--
extra : moz-landing-system : lando
This commit is contained in:
William Lachance 2020-03-16 16:42:01 +00:00
parent 6bd4554518
commit 96b10ced72
2 changed files with 17 additions and 3 deletions

View File

@ -131,9 +131,11 @@ class BaseRunner(object):
process.run(self.timeout, self.output_timeout)
self.process_handler = process
except Exception:
_, value, tb = sys.exc_info()
reraise(RunnerNotStartedError, "Failed to start the process: %s" % value, tb)
except Exception as e:
reraise(RunnerNotStartedError,
RunnerNotStartedError(
"Failed to start the process: {}".format(e)),
sys.exc_info()[2])
self.crashed = 0
return self.process_handler.pid

View File

@ -5,6 +5,10 @@ from __future__ import absolute_import
from time import sleep
import mozunit
from mock import patch
from pytest import raises
from mozrunner import RunnerNotStartedError
def test_start_process(runner):
@ -48,5 +52,13 @@ def test_start_with_outputTimeout(runner):
assert not runner.is_running()
def test_fail_to_start(runner):
with patch('mozprocess.ProcessHandler.__init__') as ph_mock:
ph_mock.side_effect = Exception('Boom!')
with raises(RunnerNotStartedError):
runner.start(outputTimeout=0.1)
sleep(1)
if __name__ == '__main__':
mozunit.main()