test(tidy): support check options and checks without a fix

- RunCheck.cmake passes a `// TIDY-CONFIG: <yaml>` 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 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-11-09 23:14:00 +00:00
parent 8ee2518fb1
commit 64ec4d7afa
2 changed files with 15 additions and 3 deletions

View File

@@ -13,6 +13,9 @@
# <code that triggers the check>
# // CHECK-FIXES: <code after the fix>
#
# A line `// TIDY-CONFIG: <yaml>` 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=<exe> -DFILECHECK=<exe> -DCHECK=<name> -DINPUT=<file>
@@ -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