diff options
author | Jeremy Bettis <jbettis@google.com> | 2022-08-16 12:23:45 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-08-16 20:04:46 +0000 |
commit | 9825445cdfa6ab45c4005d80b60897e9aed0a131 (patch) | |
tree | 4c9656069e71efef3e291ce6e1766992b42bfe45 | |
parent | 5172585c588f3bef2dd5100f2088c720332e3efc (diff) | |
download | chrome-ec-9825445cdfa6ab45c4005d80b60897e9aed0a131.tar.gz |
util: Handle failures better in check_clang_format
Instead of failing with a huge error of
`subprocess.CalledProcessError: <really long cmd>`
Just print the output if clang-format fails. Make sure though that if
clang-format fails with no output, we catch that also.
BRANCH=None
BUG=None
TEST=./util/check_clang_format.py in a client where clang-format is
broken. (update_chroot should fix it)
Signed-off-by: Jeremy Bettis <jbettis@google.com>
Change-Id: Iea2ce1f6b559bb86b23b736446b62d8640bd1432
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3833917
Tested-by: Jeremy Bettis <jbettis@chromium.org>
Reviewed-by: Tristan Honscheid <honscheid@google.com>
Commit-Queue: Tristan Honscheid <honscheid@google.com>
Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
Auto-Submit: Jeremy Bettis <jbettis@chromium.org>
-rwxr-xr-x | util/check_clang_format.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/util/check_clang_format.py b/util/check_clang_format.py index 3c62deee91..5b813c130f 100755 --- a/util/check_clang_format.py +++ b/util/check_clang_format.py @@ -48,7 +48,7 @@ def main(argv=None): result = subprocess.run( ["clang-format", "--dry-run", *clang_format_files], - check=True, + check=False, cwd=ec_dir, stderr=subprocess.PIPE, encoding="utf-8", @@ -58,6 +58,9 @@ def main(argv=None): for line in result.stderr.splitlines(): logging.error("%s", line) return 1 + if result.returncode != 0: + logging.error("clang-format failed with no output!") + return result.returncode logging.info("No clang-format issues found!") return 0 |