Skip to content

Commit

Permalink
[libcxx] [test] Don't leave test dirs behind in fs.op.current_path on…
Browse files Browse the repository at this point in the history
… Windows

Fix nesting of static_env and CWDGuard, restore the cwd (with
CWDGuard) before cleaning up the static_env.

Previously, every test run left 2 directories behind in the temp dir.

Differential Revision: https://reviews.llvm.org/D98954
  • Loading branch information
mstorsjo committed Mar 22, 2021
1 parent eb26afb commit 4c402ae
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -51,17 +51,17 @@ TEST_CASE(current_path_test)

TEST_CASE(current_path_after_change_test)
{
CWDGuard guard;
static_test_env static_env;
CWDGuard guard;
const path new_path = static_env.Dir;
current_path(new_path);
TEST_CHECK(current_path() == new_path);
}

TEST_CASE(current_path_is_file_test)
{
CWDGuard guard;
static_test_env static_env;
CWDGuard guard;
const path p = static_env.File;
std::error_code ec;
const path old_p = current_path();
Expand All @@ -72,8 +72,8 @@ TEST_CASE(current_path_is_file_test)

TEST_CASE(set_to_non_absolute_path)
{
CWDGuard guard;
static_test_env static_env;
CWDGuard guard;
const path base = static_env.Dir;
current_path(base);
const path p = static_env.Dir2.filename();
Expand Down

0 comments on commit 4c402ae

Please sign in to comment.