Files
CMake/Tests/RunCMake/FileAPI/RunCMakeTest.cmake
Brad King 276fdf2993 fileapi: Add protocol v1 support for stateful per-client queries
Add support for client-owned *stateful* query files.  These allow
clients to request a list of versions of each object kind and get only
the first-listed version that CMake recognizes.  Since clients own their
stateful query files they can mutate them over time.  As a client
installation is updated it may update the queries that it writes to
build trees to get newer object versions without paying the cost of
continuing to generate older versions.

Issue: #18398
2018-12-12 06:40:10 -05:00

46 lines
1.2 KiB
CMake

include(RunCMake)
# Function called in *-check.cmake scripts to check api files.
function(check_api expect)
file(GLOB_RECURSE actual
LIST_DIRECTORIES TRUE
RELATIVE ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1
${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/*
)
if(NOT "${actual}" MATCHES "${expect}")
set(RunCMake_TEST_FAILED "API files:
${actual}
do not match what we expected:
${expect}
in directory:
${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1" PARENT_SCOPE)
endif()
endfunction()
function(check_python case)
if(RunCMake_TEST_FAILED OR NOT PYTHON_EXECUTABLE)
return()
endif()
file(GLOB index ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply/index-*.json)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/${case}-check.py" "${index}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE output
)
if(NOT result EQUAL 0)
string(REPLACE "\n" "\n " output " ${output}")
set(RunCMake_TEST_FAILED "Unexpected index:\n${output}" PARENT_SCOPE)
endif()
endfunction()
run_cmake(Nothing)
run_cmake(Empty)
run_cmake(EmptyClient)
run_cmake(Stale)
run_cmake(SharedStateless)
run_cmake(ClientStateless)
run_cmake(MixedStateless)
run_cmake(DuplicateStateless)
run_cmake(ClientStateful)