mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Reply file names embed the configuration name verbatim. Reconfiguring a build tree with a build type that differs from the previous one only in case (e.g. Debug -> debug) makes CMake write a reply whose name also differs only in case from the existing file. On a case-insensitive filesystem the write is skipped because the name already exists, but RemoveOldReplyFiles compared on-disk names to the just-written names textually and deleted the surviving file, leaving the reply index citing a target or directory reply that no longer exists on disk. Prune reply files by file identity via cmSystemTools::GetFileId instead of by name, so an on-disk entry that aliases a reply we just wrote is kept. An entry whose identity cannot be obtained is retained rather than deleted. Fixes: #28022
22 lines
948 B
CMake
22 lines
948 B
CMake
set(reply_dir "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply")
|
|
|
|
# Every reply file referenced from the index must still exist on disk after
|
|
# the reconfigure. A dangling "jsonFile" reference is the bug this guards; it
|
|
# manifests only on a case-insensitive filesystem (Windows, default macOS).
|
|
file(GLOB reply_files "${reply_dir}/*.json")
|
|
set(dangling "")
|
|
foreach(reply_file IN LISTS reply_files)
|
|
file(READ "${reply_file}" content)
|
|
string(REGEX MATCHALL "\"jsonFile\"[ \t]*:[ \t]*\"[^\"]+\"" refs "${content}")
|
|
foreach(ref IN LISTS refs)
|
|
string(REGEX REPLACE "\"jsonFile\"[ \t]*:[ \t]*\"([^\"]+)\"" "\\1" name "${ref}")
|
|
if(NOT EXISTS "${reply_dir}/${name}")
|
|
get_filename_component(from "${reply_file}" NAME)
|
|
string(APPEND dangling "\n '${name}' referenced by ${from} is missing")
|
|
endif()
|
|
endforeach()
|
|
endforeach()
|
|
if(dangling)
|
|
set(RunCMake_TEST_FAILED "Dangling File API reply references:${dangling}")
|
|
endif()
|