summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CommandLine
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2025-04-15 12:41:36 (GMT)
committerBrad King <brad.king@kitware.com>2025-04-15 13:37:08 (GMT)
commitcd4e72ca089d7b87c80ebc6bbabfdf3b54462707 (patch)
tree83190d1a0ec44adbb879987d7e78b94a6bbf5725 /Tests/RunCMake/CommandLine
parent813f6c263e62a4a9b3e0f7e94b779bba3e5b2fd8 (diff)
downloadCMake-cd4e72ca089d7b87c80ebc6bbabfdf3b54462707.zip
CMake-cd4e72ca089d7b87c80ebc6bbabfdf3b54462707.tar.gz
CMake-cd4e72ca089d7b87c80ebc6bbabfdf3b54462707.tar.bz2
Normalize PWD environment variable before using it
In commit 5aed3ee49d (cmSystemTools: Add GetLogicalWorkingDirectory, 2024-10-28, v4.0.0-rc1~528^2~6) we incorrectly trusted `PWD` to be a normalized path so long as its realpath matches the current working directory. Fixes: #26870
Diffstat (limited to 'Tests/RunCMake/CommandLine')
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake29
1 files changed, 25 insertions, 4 deletions
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index 5c5d556..4f99358 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -896,10 +896,31 @@ run_cmake_command(E_sleep-bad-arg2 ${CMAKE_COMMAND} -E sleep 1 -1)
run_cmake_command(E_sleep-one-tenth ${CMAKE_COMMAND} -E sleep 0.1)
run_cmake_command(P_directory ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR})
-run_cmake_command(P_working-dir ${CMAKE_COMMAND} -DEXPECTED_WORKING_DIR=${RunCMake_BINARY_DIR}/P_working-dir-build -P ${RunCMake_SOURCE_DIR}/P_working-dir.cmake)
-# Documented to return the same result as above even if -S and -B are set to something else.
-# Tests the values of CMAKE_BINARY_DIR CMAKE_CURRENT_BINARY_DIR CMAKE_SOURCE_DIR CMAKE_CURRENT_SOURCE_DIR.
-run_cmake_command(P_working-dir ${CMAKE_COMMAND} -DEXPECTED_WORKING_DIR=${RunCMake_BINARY_DIR}/P_working-dir-build -P ${RunCMake_SOURCE_DIR}/P_working-dir.cmake -S something_else -B something_else_1)
+
+block()
+ set(expect ${RunCMake_BINARY_DIR}/P_working-dir-build)
+ run_cmake_script(P_working-dir -DEXPECTED_WORKING_DIR=${expect})
+
+ # -S and -B have no effect on script mode variables.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION "-S-B")
+ run_cmake_script(P_working-dir -DEXPECTED_WORKING_DIR=${expect} -S something_else -B something_else_1)
+
+ # Relative PWD is ignored.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION "-PWD-.")
+ set(RunCMake_TEST_COMMAND_PWD .)
+ run_cmake_script(P_working-dir -DEXPECTED_WORKING_DIR=${expect})
+
+ # Lower-case PWD is ignored on case-sensitive filesystems
+ # and case-normalized on case-insensitive filesystems.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION "-PWD-case")
+ string(TOLOWER "${expect}" RunCMake_TEST_COMMAND_PWD)
+ run_cmake_script(P_working-dir -DEXPECTED_WORKING_DIR=${expect})
+
+ # Backslashed PWD is normalized on Windows and ignored elsewhere.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION "-PWD-backslash")
+ string(REPLACE "/" "\\" RunCMake_TEST_COMMAND_PWD "${expect}")
+ run_cmake_script(P_working-dir -DEXPECTED_WORKING_DIR=${expect})
+endblock()
# Place an initial cache where C_basic will find it when passed the relative path "..".
file(COPY ${RunCMake_SOURCE_DIR}/C_basic_initial-cache.txt DESTINATION ${RunCMake_BINARY_DIR})