[libcxx-commits] [PATCH] D98703: [libcxx] [test] Avoid race conditions between tests regarding temp directories
Martin Storsjö via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 17 03:31:27 PDT 2021
mstorsjo updated this revision to Diff 331203.
mstorsjo added a comment.
Reupload to rerun CI (with the preceding patch detached in phabricator so it won't be applied here)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98703/new/
https://reviews.llvm.org/D98703
Files:
libcxx/test/support/filesystem_test_helper.h
Index: libcxx/test/support/filesystem_test_helper.h
===================================================================
--- libcxx/test/support/filesystem_test_helper.h
+++ libcxx/test/support/filesystem_test_helper.h
@@ -296,14 +296,17 @@
// sharing the same cwd). However, it is fairly unlikely to happen as
// we generally don't use scoped_test_env from multiple threads, so
// this is deemed acceptable.
+ // The cwd.filename() itself isn't unique across all tests in the suite,
+ // so start the numbering from a hash of the full cwd, to avoid
+ // different tests interfering with each other.
static inline fs::path available_cwd_path() {
fs::path const cwd = utils::getcwd();
fs::path const tmp = fs::temp_directory_path();
- fs::path const base = tmp / cwd.filename();
- int i = 0;
- fs::path p = base / ("static_env." + std::to_string(i));
+ std::string base = cwd.filename().string();
+ size_t i = std::hash<std::string>()(cwd.string());
+ fs::path p = tmp / (base + "-static_env." + std::to_string(i));
while (utils::exists(p.string())) {
- p = fs::path(base) / ("static_env." + std::to_string(++i));
+ p = tmp / (base + "-static_env." + std::to_string(++i));
}
return p;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98703.331203.patch
Type: text/x-patch
Size: 1328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210317/2cec0de0/attachment.bin>
More information about the libcxx-commits
mailing list