From 64ec4d7afa00879d4509e3b25008e01ced5cf0e5 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 9 Nov 2026 23:14:00 +0000 Subject: [PATCH] test(tidy): support check options and checks without a fix - RunCheck.cmake passes a `// TIDY-CONFIG: ` line of the input to --config, e.g. to set check options. - ClangdCheck.py requires a quick fix only if the input has CHECK-FIXES lines. Co-Authored-By: Claude Opus 5.5 --- test/tidy/ClangdCheck.py | 9 +++++++-- test/tidy/RunCheck.cmake | 9 ++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/test/tidy/ClangdCheck.py b/test/tidy/ClangdCheck.py index 34466a94..4fa887be 100644 --- a/test/tidy/ClangdCheck.py +++ b/test/tidy/ClangdCheck.py @@ -8,8 +8,9 @@ ################################################################################ """Runs fairmq-clangd as a language server on one test input. -The test passes if clangd publishes a diagnostic of the given check and offers -a quick fix for it, i.e. the fairmq-* checks work in an editor. +The test passes if clangd publishes a diagnostic of the given check and, if the +input has CHECK-FIXES lines, offers a quick fix for it, i.e. the fairmq-* +checks work in an editor. Usage: ClangdCheck.py """ @@ -83,6 +84,10 @@ def main(): if not found: print(f"no {check} diagnostic, got:", json.dumps(diags, indent=1)) return 1 + if "CHECK-FIXES:" not in src.read_text(): + print(f"{len(found)} {check} diagnostics") + send("shutdown", None) + return 0 req = send("textDocument/codeAction", { "textDocument": {"uri": uri}, "range": found[0]["range"], "context": {"diagnostics": [found[0]]}}) diff --git a/test/tidy/RunCheck.cmake b/test/tidy/RunCheck.cmake index 06f12629..8235eab2 100644 --- a/test/tidy/RunCheck.cmake +++ b/test/tidy/RunCheck.cmake @@ -13,6 +13,9 @@ # # // CHECK-FIXES: # +# A line `// TIDY-CONFIG: ` passes the YAML to --config, e.g. to set +# check options. +# # Any warning or error without a CHECK-MESSAGES line fails the test. # # Usage: cmake -DTIDY= -DFILECHECK= -DCHECK= -DINPUT= @@ -40,8 +43,12 @@ set(load) if(LOAD) set(load "--load=${LOAD}") endif() +set(config) +if(content MATCHES "// *TIDY-CONFIG: *([^\n]*)") + set(config "--config=${CMAKE_MATCH_1}") +endif() execute_process( - COMMAND "${TIDY}" ${load} "--checks=-*,${CHECK}" --fix "${fixed}" -- ${flags} + COMMAND "${TIDY}" ${load} ${config} "--checks=-*,${CHECK}" --fix "${fixed}" -- ${flags} OUTPUT_FILE "${messages}" ERROR_VARIABLE stderr RESULT_VARIABLE result