From 70cdb274f0ccc1bef8e1d4df40bced031d5ff5b2 Mon Sep 17 00:00:00 2001 From: Tyler Rockwood Date: Thu, 31 Jul 2025 10:36:50 -0500 Subject: [PATCH] fix run_clang_tidy.sh error printing The trap wasn't firing before, so rewrite as an if statement. --- clang_tidy/run_clang_tidy.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/clang_tidy/run_clang_tidy.sh b/clang_tidy/run_clang_tidy.sh index 8b373d4..f881663 100755 --- a/clang_tidy/run_clang_tidy.sh +++ b/clang_tidy/run_clang_tidy.sh @@ -19,7 +19,6 @@ truncate -s 0 $OUTPUT # Print output on failure only logfile="$(mktemp)" -trap 'if (($?)); then cat "$logfile" 1>&2; fi; rm "$logfile"' EXIT # Prepend a flag-based disabling of a check that has a serious bug in # clang-tidy 16 when used with C++20. Bazel always violates this check and the @@ -33,7 +32,15 @@ set -- \ --warnings-as-errors=-clang-diagnostic-builtin-macro-redefined \ "$@" -{ +if { "${CLANG_TIDY_BIN}" --config-file=$CONFIG --quiet --verify-config && "${CLANG_TIDY_BIN}" --config-file=$CONFIG "$@" -} >"$logfile" 2>&1 +} >"$logfile" 2>&1; then + # Success - just remove the logfile + rm -f "$logfile" +else + # Failure - print the log and exit with error + cat "$logfile" 1>&2 + rm -f "$logfile" + exit 1 +fi