From 6908e47768c298d0c25e4e67f4d61873ba2286a6 Mon Sep 17 00:00:00 2001 From: Wyatt Hepler Date: Tue, 4 Feb 2020 12:24:07 -0800 Subject: [PATCH] pw_presubmit: Add message about the Bazel cache Sometimes the Bazel cache gets in a bad state where it complains about undeclared inclusions on C standard library headers. The only way to fix this is to delete the Bazel cache. This adds a message to the presubmit about how to clear the cache if the Bazel build fails. Fixed: 114 Change-Id: I7c3ad45bdce919a325f721f2071e99c1e56582c0 --- .../py/pw_presubmit/pigweed_presubmit.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py b/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py index 5a18e396f..dc3408aa8 100755 --- a/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py +++ b/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py @@ -280,15 +280,21 @@ CMAKE = (cmake_tests, ) # @filter_paths(endswith=(*format_code.C_FORMAT.extensions, '.bzl', 'BUILD')) def bazel_test(ctx: PresubmitContext): - call('bazel', - 'test', - '//...', - '--verbose_failures', - '--verbose_explanations', - '--worker_verbose', - '--symlink_prefix', - ctx.output_directory.joinpath('bazel-'), - cwd=ctx.repository_root) + try: + call('bazel', + 'test', + '//...', + '--verbose_failures', + '--verbose_explanations', + '--worker_verbose', + '--symlink_prefix', + ctx.output_directory.joinpath('bazel-'), + cwd=ctx.repository_root) + except: + _LOG.info('If the Bazel build inexplicably fails while the ' + 'other builds are passing, try deleting the Bazel cache:\n' + ' rm -rf ~/.cache/bazel') + raise BAZEL = (bazel_test, )