From ff48c8d4d2d3c99e552e512546a6de6cd799a7ca Mon Sep 17 00:00:00 2001 From: Martin Duffy Date: Wed, 16 Sep 2026 13:12:03 -0400 Subject: [PATCH] Tests/Instrumentation: Fix exponential output spam from validate_json_schema Schema validations in Tests/Instrumentation called add_error("${RunCMake_TEST_FAILED}") in a loop. Because add_error itself appends the input to RunCMake_TEST_FAILED, this resulted in exponential growth of error messages on each loop iteration, filling the test log with duplicate errors. Isolate error messages from validate_json_schema to avoid exponential duplication. --- .../Instrumentation/check-query-dir.cmake | 19 ++++++++++++------- .../Instrumentation/verify-snippet.cmake | 11 ++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Tests/RunCMake/Instrumentation/check-query-dir.cmake b/Tests/RunCMake/Instrumentation/check-query-dir.cmake index 38bbfbbaec..221ed92101 100644 --- a/Tests/RunCMake/Instrumentation/check-query-dir.cmake +++ b/Tests/RunCMake/Instrumentation/check-query-dir.cmake @@ -6,15 +6,20 @@ set(schema_file "${CMAKE_CURRENT_LIST_DIR}/../../../Help/manual/instrumentation/ file(GLOB_RECURSE queries LIST_DIRECTORIES false ${v1}/query/*) foreach(query ${queries}) - validate_json_schema( - "${schema_file}" "${query}" - EXPECTED_RESULT "${schema_validate_result}" - ) - if (RunCMake_TEST_FAILED) - add_error("${RunCMake_TEST_FAILED}") + block(SCOPE_FOR VARIABLES PROPAGATE schema_error) + # Capture only the error message from this validate_json_chema call + set(RunCMake_TEST_FAILED "") + validate_json_schema( + "${schema_file}" "${query}" + EXPECTED_RESULT "${schema_validate_result}" + ) + set(schema_error "${RunCMake_TEST_FAILED}") + endblock() + if (schema_error) + add_error("${schema_error}") endif() endforeach() if (ERROR_MESSAGE) - message(FATAL_ERROR ${ERROR_MESSAGE}) + message(FATAL_ERROR "${ERROR_MESSAGE}") endif() diff --git a/Tests/RunCMake/Instrumentation/verify-snippet.cmake b/Tests/RunCMake/Instrumentation/verify-snippet.cmake index fe89acb3a4..a2597fb032 100644 --- a/Tests/RunCMake/Instrumentation/verify-snippet.cmake +++ b/Tests/RunCMake/Instrumentation/verify-snippet.cmake @@ -112,9 +112,14 @@ function(verify_snippet_file snippet contents) endif() set(snippet_schema "${CMAKE_CURRENT_LIST_DIR}/../../../Help/manual/instrumentation/snippet-v1-schema.json") - validate_json_schema("${snippet_schema}" "${snippet}") - if (RunCMake_TEST_FAILED) - add_error("${RunCMake_TEST_FAILED}") + block(SCOPE_FOR VARIABLES PROPAGATE schema_error) + # Capture only the error message from this validate_json_chema call + set(RunCMake_TEST_FAILED "") + validate_json_schema("${snippet_schema}" "${snippet}") + set(schema_error "${RunCMake_TEST_FAILED}") + endblock() + if (schema_error) + add_error("${schema_error}") endif() return(PROPAGATE ERROR_MESSAGE RunCMake_TEST_FAILED role)