From b5e228fc00b18b1ce2ac823fe61b03b07600a9ad Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Storsj=C3=B6?= Date: Fri, 26 Feb 2021 15:15:36 +0200 Subject: [PATCH] [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 --- .../fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp index c996142..32748de 100644 --- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp +++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp @@ -55,10 +55,16 @@ TEST_CASE(basic_tests) std::string name; path p; } cases[] = { +#ifdef _WIN32 + {"TMP", env.create_dir("dir1")}, + {"TEMP", env.create_dir("dir2")}, + {"USERPROFILE", env.create_dir("dir3")} +#else {"TMPDIR", env.create_dir("dir1")}, {"TMP", env.create_dir("dir2")}, {"TEMP", env.create_dir("dir3")}, {"TEMPDIR", env.create_dir("dir4")} +#endif }; for (auto& TC : cases) { PutEnv(TC.name, TC.p); @@ -112,7 +118,10 @@ TEST_CASE(basic_tests) std::error_code ec = GetTestEC(); path ret = temp_directory_path(ec); TEST_CHECK(!ec); +#ifndef _WIN32 + // On Windows, the function falls back to the Windows folder. TEST_CHECK(ret == "/tmp"); +#endif TEST_CHECK(is_directory(ret)); } } -- 2.7.4