diff options
author | Brad King <brad.king@kitware.com> | 2021-03-08 18:18:18 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-03-08 18:18:24 (GMT) |
commit | 1982264c17233c274879ad1b688064f0624ded1f (patch) | |
tree | 8589a17fe7609d68691ff3feeb6a0db5a4ece92c | |
parent | b7cd44e48234ec02406fa057f6ee1850635acf60 (diff) | |
parent | 31be23dd1d61db80656159adbcf915a609b8692f (diff) | |
download | CMake-1982264c17233c274879ad1b688064f0624ded1f.zip CMake-1982264c17233c274879ad1b688064f0624ded1f.tar.gz CMake-1982264c17233c274879ad1b688064f0624ded1f.tar.bz2 |
Merge topic 'ExternalData-windows'
31be23dd1d ci: Restore the Module.ExternalData test on Windows
fdfbf89f0c ExternalData: Avoid replacing a concurrently-created object
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !5883
-rw-r--r-- | .gitlab/ci/ctest_exclusions.cmake | 9 | ||||
-rw-r--r-- | Modules/ExternalData.cmake | 9 |
2 files changed, 8 insertions, 10 deletions
diff --git a/.gitlab/ci/ctest_exclusions.cmake b/.gitlab/ci/ctest_exclusions.cmake index a68a693..b885a6a 100644 --- a/.gitlab/ci/ctest_exclusions.cmake +++ b/.gitlab/ci/ctest_exclusions.cmake @@ -13,15 +13,6 @@ if (CTEST_CMAKE_GENERATOR MATCHES "Visual Studio") "^ExternalProjectUpdateSetup$") endif () -if (CMAKE_HOST_WIN32) - list(APPEND test_exclusions - # This test often fails with an undiagnosed subtle race due to the test - # re-using the same objects for many files. Some copy operations fail - # to open their input with ERROR_SHARING_VIOLATION. - "^Module.ExternalData$" - ) -endif() - string(REPLACE ";" "|" test_exclusions "${test_exclusions}") if (test_exclusions) set(test_exclusions "(${test_exclusions})") diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index d6fbae9..b439636 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -1101,7 +1101,14 @@ function(_ExternalData_download_object name hash algo var_obj var_success var_er set(success 1) if(found) - file(RENAME "${tmp}" "${obj}") + # Atomically create the object. If we lose a race with another process, + # do not replace it. Content-addressing ensures it has what we expect. + file(RENAME "${tmp}" "${obj}" NO_REPLACE RESULT result) + if (result STREQUAL "NO_REPLACE") + file(REMOVE "${tmp}") + elseif (result) + message(FATAL_ERROR "Failed to rename:\n \"${tmp}\"\nto:\n \"${obj}\"\nwith error:\n ${result}") + endif() message(STATUS "Downloaded object: \"${obj}\"") elseif(EXISTS "${staged}") set(obj "${staged}") |