зеркало из https://github.com/mozilla/gecko-dev.git
Bug 807974 - Handle make errors more gracefully; r=jhammel
We now return the status code from executed processes. The API to require a successful status code has been changed from ignore_errors to ensure_exit_code. The build mach command no longer spews a stack trace if make fails. DONTBUILD (NPOTB)
This commit is contained in:
Родитель
57be670bf6
Коммит
26d1f2eb12
|
@ -43,7 +43,7 @@ class ProcessExecutionMixin(LoggingMixin):
|
|||
def run_process(self, args=None, cwd=None, append_env=None,
|
||||
explicit_env=None, log_name=None, log_level=logging.INFO,
|
||||
line_handler=None, require_unix_environment=False,
|
||||
ignore_errors=False, ignore_children=False):
|
||||
ensure_exit_code=0, ignore_children=False):
|
||||
"""Runs a single process to completion.
|
||||
|
||||
Takes a list of arguments to run where the first item is the
|
||||
|
@ -60,6 +60,11 @@ class ProcessExecutionMixin(LoggingMixin):
|
|||
execute the command via an appropriate UNIX-like shell.
|
||||
|
||||
ignore_children is proxied to mozprocess's ignore_children.
|
||||
|
||||
ensure_exit_code is used to ensure the exit code of a process matches
|
||||
what is expected. If it is an integer, we raise an Exception is the
|
||||
exit code does not match this value. If it is True, we ensure the exit
|
||||
code is 0. If it is False, we don't perform any exit code validation.
|
||||
"""
|
||||
args = self._normalize_command(args, require_unix_environment)
|
||||
|
||||
|
@ -96,9 +101,17 @@ class ProcessExecutionMixin(LoggingMixin):
|
|||
p.processOutput()
|
||||
status = p.wait()
|
||||
|
||||
if status != 0 and not ignore_errors:
|
||||
if ensure_exit_code is False:
|
||||
return status
|
||||
|
||||
if ensure_exit_code is True:
|
||||
ensure_exit_code = 0
|
||||
|
||||
if status != ensure_exit_code:
|
||||
raise Exception('Process executed with non-0 exit code: %s' % args)
|
||||
|
||||
return status
|
||||
|
||||
def _normalize_command(self, args, require_unix_environment):
|
||||
"""Adjust command arguments to run in the necessary environment.
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ class MozbuildObject(ProcessExecutionMixin):
|
|||
def _run_make(self, directory=None, filename=None, target=None, log=True,
|
||||
srcdir=False, allow_parallel=True, line_handler=None,
|
||||
append_env=None, explicit_env=None, ignore_errors=False,
|
||||
silent=True, print_directory=True):
|
||||
ensure_exit_code=0, silent=True, print_directory=True):
|
||||
"""Invoke make.
|
||||
|
||||
directory -- Relative directory to look for Makefile in.
|
||||
|
@ -224,7 +224,7 @@ class MozbuildObject(ProcessExecutionMixin):
|
|||
'explicit_env': explicit_env,
|
||||
'log_level': logging.INFO,
|
||||
'require_unix_environment': True,
|
||||
'ignore_errors': ignore_errors,
|
||||
'ensure_exit_code': ensure_exit_code,
|
||||
|
||||
# Make manages its children, so mozprocess doesn't need to bother.
|
||||
# Having mozprocess manage children can also have side-effects when
|
||||
|
@ -235,7 +235,7 @@ class MozbuildObject(ProcessExecutionMixin):
|
|||
if log:
|
||||
params['log_name'] = 'make'
|
||||
|
||||
fn(**params)
|
||||
return fn(**params)
|
||||
|
||||
@property
|
||||
def _make_path(self):
|
||||
|
@ -258,10 +258,10 @@ class MozbuildObject(ProcessExecutionMixin):
|
|||
return self._make
|
||||
|
||||
def _run_command_in_srcdir(self, **args):
|
||||
self.run_process(cwd=self.topsrcdir, **args)
|
||||
return self.run_process(cwd=self.topsrcdir, **args)
|
||||
|
||||
def _run_command_in_objdir(self, **args):
|
||||
self.run_process(cwd=self.topobjdir, **args)
|
||||
return self.run_process(cwd=self.topobjdir, **args)
|
||||
|
||||
def _is_windows(self):
|
||||
return os.name in ('nt', 'ce')
|
||||
|
|
|
@ -49,8 +49,9 @@ class Build(MachCommandBase):
|
|||
|
||||
self.log(logging.INFO, 'build_output', {'line': line}, '{line}')
|
||||
|
||||
self._run_make(srcdir=True, filename='client.mk', line_handler=on_line,
|
||||
log=False, print_directory=False)
|
||||
status = self._run_make(srcdir=True, filename='client.mk',
|
||||
line_handler=on_line, log=False, print_directory=False,
|
||||
ensure_exit_code=False)
|
||||
|
||||
self.log(logging.WARNING, 'warning_summary',
|
||||
{'count': len(warnings_collector.database)},
|
||||
|
@ -58,6 +59,8 @@ class Build(MachCommandBase):
|
|||
|
||||
warnings_database.save_to_file(warnings_path)
|
||||
|
||||
return status
|
||||
|
||||
|
||||
@CommandProvider
|
||||
class Warnings(MachCommandBase):
|
||||
|
|
Загрузка…
Ссылка в новой задаче