diff options
author | Simon Glass <sjg@chromium.org> | 2021-03-28 15:22:58 +1300 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-30 20:53:08 +0000 |
commit | 63bbb9735ec8656ebf5804b8319e79f589c037ed (patch) | |
tree | 78ff186ec5be84796d68d7e39c101906005fadeb /zephyr/zmake | |
parent | 6f2ef7024b1dacacd4e117f781ac302c62e29cfc (diff) | |
download | chrome-ec-63bbb9735ec8656ebf5804b8319e79f589c037ed.tar.gz |
zmake: Use a common function to report a failure message
At present when zmake fails the resulting messages is independently
created in a different place for each subcommand.
Move this in a common function, so we can make it consistent.
Also adjust the output to show the command at the end, in case the
user wants to copy it out and try it. Drop the exclaimation mark since
errors are not all that exciting.
BUG=b:177096315
BRANCH=none
TEST=manually test by running zmake configure / build
Signed-off-by: Simon Glass <sjg@chromium.org>
Change-Id: I913c3c86dcd257ed8a7f5d378b38e31d7c6d6465
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2788843
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/zmake')
-rw-r--r-- | zephyr/zmake/zmake/zmake.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py index 0d47502946..6ebab8da76 100644 --- a/zephyr/zmake/zmake/zmake.py +++ b/zephyr/zmake/zmake/zmake.py @@ -35,6 +35,19 @@ def ninja_log_level_override(line, default_log_level): return default_log_level +def get_process_failure_msg(proc): + """Creates a suitable failure message if something exits badly + + Args: + proc: subprocess.Popen object containing the thing that failed + + Returns: + Failure message as a string: + """ + return "Execution failed (return code={}): {}\n".format( + proc.returncode, util.repr_command(proc.args)) + + class Zmake: """Wrapper class encapsulating zmake's supported operations. @@ -176,9 +189,7 @@ class Zmake: processes.append(proc) for proc in processes: if proc.wait(): - raise OSError( - "Execution of {} failed (return code={})!\n".format( - util.repr_command(proc.args), proc.returncode)) + raise OSError(get_process_failure_msg(proc)) # Create symlink to project util.update_symlink(project_dir, build_dir / 'project') @@ -216,9 +227,7 @@ class Zmake: for proc in procs: if proc.wait(): - raise OSError( - "Execution of {} failed (return code={})!\n".format( - util.repr_command(proc.args), proc.returncode)) + raise OSError(get_process_failure_msg(proc)) # Run the packer. packer_work_dir = build_dir / 'packer' @@ -263,9 +272,7 @@ class Zmake: for idx, proc in enumerate(procs): if proc.wait(): - raise OSError( - "Execution of {} failed (return code={})!\n".format( - util.repr_command(proc.args), proc.returncode)) + raise OSError(get_process_failure_msg(proc)) return 0 def _run_pytest(self, executor, directory): @@ -305,9 +312,7 @@ class Zmake: proc.stdout, log_level_override_func=get_log_level) rv = proc.wait() if rv: - self.logger.error( - "Execution of {} failed (return code={})!\n".format( - util.repr_command(proc.args), rv)) + self.logger.error(get_process_failure_msg(proc)) return rv for test_file in directory.glob('test_*.py'): |