diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp --- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp +++ b/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)