Skip to content

Commit b5e228f

Browse files
committed
[libcxx] [test] Fix the temp_directory_path test for windows
Check a different set of env vars, don't check the exact value of the fallback path. (GetTempPath falls back to returning the Windows folder if nothing better is available in env vars.) The test still fails one check on windows (due to relying on perms::none), which will be addressed separately. Differential Revision: https://reviews.llvm.org/D98139
1 parent edf634e commit b5e228f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,16 @@ TEST_CASE(basic_tests)
5555
std::string name;
5656
path p;
5757
} cases[] = {
58+
#ifdef _WIN32
59+
{"TMP", env.create_dir("dir1")},
60+
{"TEMP", env.create_dir("dir2")},
61+
{"USERPROFILE", env.create_dir("dir3")}
62+
#else
5863
{"TMPDIR", env.create_dir("dir1")},
5964
{"TMP", env.create_dir("dir2")},
6065
{"TEMP", env.create_dir("dir3")},
6166
{"TEMPDIR", env.create_dir("dir4")}
67+
#endif
6268
};
6369
for (auto& TC : cases) {
6470
PutEnv(TC.name, TC.p);
@@ -112,7 +118,10 @@ TEST_CASE(basic_tests)
112118
std::error_code ec = GetTestEC();
113119
path ret = temp_directory_path(ec);
114120
TEST_CHECK(!ec);
121+
#ifndef _WIN32
122+
// On Windows, the function falls back to the Windows folder.
115123
TEST_CHECK(ret == "/tmp");
124+
#endif
116125
TEST_CHECK(is_directory(ret));
117126
}
118127
}

0 commit comments

Comments
 (0)