Files
CMake/Tests/RunCMake/FileAPI/RunCMakeTest.cmake
Brad King eb2ec41a04 fileapi: Add protocol v1 infrastructure with support for shared query files
Add a file-based API that clients may use to get semantic information
about the buildsystem that CMake generates.  Clients will write query
files under a designated location in the build tree, and CMake will
write reply files for clients to read.

Start with support for shared stateless query files.  These allow
clients to share requests for major object versions and get all those
recognized by CMake.  Once any client has written a shared request to a
build tree it will persist.  Other clients will not need to overwrite
the request (since it is stateless) and should not remove it either.

For now we add only an undocumented object kind to use for testing the
query and reply infrastructure.  Object kinds providing real semantic
information will be added later.

Issue: #18398
2018-12-12 06:39:30 -05:00

41 lines
1.1 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(Stale)
run_cmake(SharedStateless)