Tests: Add case covering non-writable CMAKE_BINARY_DIR

Issue: #24407
This commit is contained in:
Brad King
2023-11-30 14:20:32 -05:00
parent d91c02e40f
commit 0fd64345fe
4 changed files with 26 additions and 0 deletions

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1,8 @@
CMake Error: Unable to \(re\)create the private pkgRedirects directory:
[^
]*/Tests/RunCMake/Configure/ReadOnly-build/CMakeFiles/pkgRedirects
This may be caused by not having read/write access to the build directory.
Try specifying a location with read/write access like:
cmake -B build
If using a CMake presets file, ensure that preset parameter
'binaryDir' expands to a writable directory.

View File

@@ -0,0 +1 @@
message(FATAL_ERROR "This should not be reached!")

View File

@@ -55,3 +55,19 @@ if(NOT RunCMake_GENERATOR MATCHES "^Ninja Multi-Config$")
run_cmake(NoCMAKE_DEFAULT_BUILD_TYPE)
run_cmake(NoCMAKE_DEFAULT_CONFIGS)
endif()
if(NOT CMAKE_HOST_WIN32)
block()
# Test a non-writable build directory.
# Exclude when running as root because directories are always writable.
get_unix_uid(uid)
if(NOT uid STREQUAL "0")
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ReadOnly-build)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
file(CHMOD "${RunCMake_TEST_BINARY_DIR}" PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake(ReadOnly)
endif()
endblock()
endif()