Skip to content

fix run_clang_tidy.sh error printing #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions clang_tidy/run_clang_tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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