mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-09 23:44:00 +03:00
Merge topic 'normalize-input-paths' into release-4.0
cd4e72ca08 Normalize PWD environment variable before using it
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10659
This commit is contained in:
commit
699f45ae33
3 files changed
+34
-8
No files matched your search
@@ -3007,10 +3007,11 @@ std::string InitLogicalWorkingDirectory()
|
||||
{
|
||||
std::string cwd = cmsys::SystemTools::GetCurrentWorkingDirectory();
|
||||
std::string pwd;
|
||||
if (cmSystemTools::GetEnv("PWD", pwd)) {
|
||||
if (cmSystemTools::GetEnv("PWD", pwd) &&
|
||||
cmSystemTools::FileIsFullPath(pwd)) {
|
||||
std::string const pwd_real = cmSystemTools::GetRealPath(pwd);
|
||||
if (pwd_real == cwd) {
|
||||
cwd = std::move(pwd);
|
||||
cwd = cmSystemTools::ToNormalizedPathOnDisk(std::move(pwd));
|
||||
}
|
||||
}
|
||||
return cwd;
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -164,8 +164,12 @@ function(run_cmake test)
|
||||
else()
|
||||
set(old_pwd)
|
||||
endif()
|
||||
# Emulate a shell using this directory.
|
||||
set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}")
|
||||
if(RunCMake_TEST_COMMAND_PWD)
|
||||
set(ENV{PWD} "${RunCMake_TEST_COMMAND_PWD}")
|
||||
else()
|
||||
# Emulate a shell using this directory.
|
||||
set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}")
|
||||
endif()
|
||||
cmake_language(EVAL CODE "${_code}")
|
||||
if(DEFINED old_pwd)
|
||||
set(ENV{PWD} "${old_pwd}")
|
||||
|
||||
Reference in new issue
Block a user