From 7c7278c9fa91471f7197455bcd8c2d1ffdd0ddeb Mon Sep 17 00:00:00 2001 From: Oliver Lee Date: Mon, 30 Sep 2024 20:22:53 -0700 Subject: [PATCH] suppress stderr on success (#27) Change-Id: I835b46a9aa5298841b995aa95dd351d9c3347165 --- make_clang_tidy_aspect.bzl | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/make_clang_tidy_aspect.bzl b/make_clang_tidy_aspect.bzl index f1bbdba..e5949dc 100644 --- a/make_clang_tidy_aspect.bzl +++ b/make_clang_tidy_aspect.bzl @@ -85,7 +85,6 @@ def _do_tidy(ctx, compilation_ctx, source_file, **kwargs): transitive = [compilation_ctx.headers], ), outputs = [fixes, result, stdout, stderr], - arguments = [str(not kwargs["display_stderr"]).lower()], command = """\ #!/usr/bin/env bash set -euo pipefail @@ -99,8 +98,6 @@ set -euo pipefail -- {compiler_command} > {stdout} 2> {stderr} && echo "true" > {result}) \ || (cat {stderr} >&2 && echo "false" > {result}) -$1 || cat {stderr} - touch {fixes} # replace sandbox path prefix from file paths and @@ -142,9 +139,12 @@ sed "$SED_INPLACE" -e "s+$(pwd)+%workspace%+g" {fixes} #!/usr/bin/env bash set -euo pipefail -cat {stdout} ->&2 cat {stderr} -bash {result} +if ! $(cat {result}); then + cat {stdout} + >&2 cat {stderr} + false +fi + touch {phony} """.format( result = result.path, @@ -204,7 +204,6 @@ def make_clang_tidy_aspect( clang_tidy = None, config = None, options = [], - display_stderr = False, execution_requirements = None): """ Creates an aspect to run ClangTidy. @@ -224,11 +223,6 @@ def make_clang_tidy_aspect( options: List of strings; default is [] A list of options passed to ClangTidy. - display_stderr: `bool`; default is `False` - Display stderr when ClangTidy runs successfully. Setting this to - `False` is quieter than the `--quiet` option and can be used to - suppress messages about the number of generated warnings. - execution_requirements: `dict`; or `None`; default is `None` Information for scheduling the action. https://bazel.build/reference/be/common-definitions#common.tags @@ -239,7 +233,6 @@ def make_clang_tidy_aspect( return aspect( implementation = _clang_tidy_aspect_impl( tidy_options = options, - display_stderr = display_stderr, execution_requirements = execution_requirements, ), fragments = ["cpp"],