mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 10:50:16 -06:00
Tests: Fix regex matching to handle paths with special characters
Use `string(REGEX QUOTE)` for `MATCHES` with constructed patterns. Fixes: #27234
This commit is contained in:
@@ -2,7 +2,8 @@ file(READ "${RunCMake_TEST_BINARY_DIR}/out.txt" content)
|
||||
|
||||
unset(RunCMake_TEST_FAILED)
|
||||
|
||||
if (NOT content MATCHES "(INCLUDES1:${RunCMake_TEST_SOURCE_DIR}/include)")
|
||||
string(REGEX QUOTE RunCMake_TEST_SOURCE_DIR_regex "${RunCMake_TEST_SOURCE_DIR}")
|
||||
if (NOT content MATCHES "(INCLUDES1:${RunCMake_TEST_SOURCE_DIR_regex}/include)")
|
||||
string(APPEND RunCMake_TEST_FAILED "wrong content for INCLUDES1: \"${CMAKE_MATCH_1}\"\n")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
include(${RunCMake_SOURCE_DIR}/TARGETS-FILE_RPATH_CHANGE-check-common.cmake)
|
||||
skip_without_rpath_change_rule()
|
||||
string(APPEND prefix "${wsnl}" [[FILE "[^"]*/]])
|
||||
string(REGEX QUOTE RunCMake_BINARY_DIR_regex "${RunCMake_BINARY_DIR}")
|
||||
|
||||
set(target "exe1")
|
||||
string(CONCAT regex "${prefix}${target}\"${wsnl}"
|
||||
[[OLD_RPATH "]] "${RunCMake_BINARY_DIR}")
|
||||
[[OLD_RPATH "]] "${RunCMake_BINARY_DIR_regex}")
|
||||
check()
|
||||
|
||||
if("x${CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN}" STREQUAL "x\$ORIGIN")
|
||||
|
||||
@@ -12,7 +12,8 @@ target_include_directories(main AFTER PRIVATE "${after_include_dir}")
|
||||
|
||||
get_target_property(actual_include_dirs main INCLUDE_DIRECTORIES)
|
||||
set(desired_include_dirs "${include_dir}" "${after_include_dir}")
|
||||
string(REGEX QUOTE desired_include_dirs_regex "${desired_include_dirs}")
|
||||
|
||||
if (NOT "${actual_include_dirs}" MATCHES "${desired_include_dirs}")
|
||||
if (NOT "${actual_include_dirs}" MATCHES "^${desired_include_dirs_regex}$")
|
||||
message(SEND_ERROR "include after does not work")
|
||||
endif()
|
||||
|
||||
@@ -12,7 +12,8 @@ target_include_directories(main BEFORE PRIVATE "${before_include_dir}")
|
||||
|
||||
get_target_property(actual_include_dirs main INCLUDE_DIRECTORIES)
|
||||
set(desired_include_dirs "${before_include_dir}" "${include_dir}")
|
||||
string(REGEX QUOTE desired_include_dirs_regex "${desired_include_dirs}")
|
||||
|
||||
if (NOT "${actual_include_dirs}" MATCHES "${desired_include_dirs}")
|
||||
if (NOT "${actual_include_dirs}" MATCHES "^${desired_include_dirs_regex}$")
|
||||
message(SEND_ERROR "include before does not work")
|
||||
endif()
|
||||
|
||||
@@ -12,7 +12,8 @@ target_include_directories(main AFTER PRIVATE "${default_include_dir}")
|
||||
|
||||
get_target_property(actual_include_dirs main INCLUDE_DIRECTORIES)
|
||||
set(desired_include_dirs "${include_dir}" "${default_include_dir}")
|
||||
string(REGEX QUOTE desired_include_dirs_regex "${desired_include_dirs}")
|
||||
|
||||
if (NOT "${actual_include_dirs}" MATCHES "${desired_include_dirs}")
|
||||
if (NOT "${actual_include_dirs}" MATCHES "^${desired_include_dirs_regex}$")
|
||||
message(SEND_ERROR "include default does not work")
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user