[libcxx-commits] [PATCH] D98954: [libcxx] [test] Don't leave test dirs behind in fs.op.current_path on Windows
Martin Storsjö via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 19 07:59:10 PDT 2021
mstorsjo created this revision.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.
Previously, every test run left 2 directories behind in the temp dir.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98954
Files:
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp
Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp
+++ libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp
@@ -53,9 +53,14 @@
{
CWDGuard guard;
static_test_env static_env;
+ const path orig_cwd = current_path();
const path new_path = static_env.Dir;
current_path(new_path);
TEST_CHECK(current_path() == new_path);
+
+ // Restore the original current_path before cleaning up static_env;
+ // the dir can't be cleaned up if it's in use on Windows.
+ current_path(orig_cwd);
}
TEST_CASE(current_path_is_file_test)
@@ -74,6 +79,7 @@
{
CWDGuard guard;
static_test_env static_env;
+ const path orig_cwd = current_path();
const path base = static_env.Dir;
current_path(base);
const path p = static_env.Dir2.filename();
@@ -83,6 +89,10 @@
const path new_cwd = current_path();
TEST_CHECK(new_cwd == static_env.Dir2);
TEST_CHECK(new_cwd.is_absolute());
+
+ // Restore the original current_path before cleaning up static_env;
+ // the dir can't be cleaned up if it's in use on Windows.
+ current_path(orig_cwd);
}
TEST_CASE(set_to_empty)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98954.331879.patch
Type: text/x-patch
Size: 1384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210319/603af342/attachment.bin>
More information about the libcxx-commits
mailing list