mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
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.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user