Bug 1451310 - [mozrunner] Catch exceptions when starting the client process. r=ahal

If a ProcessHandler instance has been created, but mozprocess fails
to start the child process, a dangling process_handler instance is
attached to the runner instance. This should be avoided, and a
RunnerNotStartedError has to be thrown.

MozReview-Commit-ID: LgNFVaT9qVs

--HG--
extra : rebase_source : c06aef08d7619ac9d3fe94ad29bdae06f0f79364
This commit is contained in:
Henrik Skupin 2018-04-04 15:04:42 +02:00
Родитель ac11d47831
Коммит 4c98f9ad50
2 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -17,6 +17,7 @@ try:
import mozcrash
except ImportError:
mozcrash = None
from six import reraise
from ..application import DefaultContext
from ..errors import RunnerNotStartedError
@ -97,6 +98,8 @@ class BaseRunner(object):
:param timeout: see process_handler.run()
:param outputTimeout: see process_handler.run()
:returns: the process id
:raises: RunnerNotStartedError
"""
self.timeout = timeout
self.output_timeout = outputTimeout
@ -126,8 +129,14 @@ class BaseRunner(object):
# TODO: other arguments
else:
# this run uses the managed processhandler
self.process_handler = self.process_class(cmd, env=encoded_env, **self.process_args)
self.process_handler.run(self.timeout, self.output_timeout)
try:
process = self.process_class(cmd, env=encoded_env, **self.process_args)
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)
self.crashed = 0
return self.process_handler.pid

Просмотреть файл

@ -18,6 +18,7 @@ deps = ['mozdevice >= 0.37',
'mozlog >= 3.0',
'mozprocess >= 0.23',
'mozprofile >= 0.18',
'six >= 1.10.0',
]
EXTRAS_REQUIRE = {'crash': ['mozcrash >= 1.0']}