[libcxx-commits] [libcxx] c9fc1a9 - [libcxx] [test] Explicitly check that some env vars are ignored in the temp_dir_path test
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 19 00:33:51 PDT 2021
Author: Martin Storsjö
Date: 2021-03-19T09:33:26+02:00
New Revision: c9fc1a979cbaf86b00e66140a235f5fdc1250bc5
URL: https://github.com/llvm/llvm-project/commit/c9fc1a979cbaf86b00e66140a235f5fdc1250bc5
DIFF: https://github.com/llvm/llvm-project/commit/c9fc1a979cbaf86b00e66140a235f5fdc1250bc5.diff
LOG: [libcxx] [test] Explicitly check that some env vars are ignored in the temp_dir_path test
This was suggested in the review of D98139.
Differential Revision: https://reviews.llvm.org/D98696
Added:
Modified:
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
Removed:
################################################################################
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 32748ded1428..28331c77b9a5 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
@@ -64,6 +64,14 @@ TEST_CASE(basic_tests)
{"TMP", env.create_dir("dir2")},
{"TEMP", env.create_dir("dir3")},
{"TEMPDIR", env.create_dir("dir4")}
+#endif
+ };
+ TestCase ignored_cases[] = {
+#ifdef _WIN32
+ {"TMPDIR", env.create_dir("dir5")},
+ {"TEMPDIR", env.create_dir("dir6")},
+#else
+ {"USERPROFILE", env.create_dir("dir5")},
#endif
};
for (auto& TC : cases) {
@@ -114,6 +122,7 @@ TEST_CASE(basic_tests)
UnsetEnv(TC.name);
}
// No env variables are defined
+ path fallback;
{
std::error_code ec = GetTestEC();
path ret = temp_directory_path(ec);
@@ -123,6 +132,20 @@ TEST_CASE(basic_tests)
TEST_CHECK(ret == "/tmp");
#endif
TEST_CHECK(is_directory(ret));
+ fallback = ret;
+ }
+ for (auto& TC : ignored_cases) {
+ // Check that certain variables are ignored
+ PutEnv(TC.name, TC.p);
+ std::error_code ec = GetTestEC();
+ path ret = temp_directory_path(ec);
+ TEST_CHECK(!ec);
+
+ // Check that we return the same as above when no vars were defined.
+ TEST_CHECK(ret == fallback);
+
+ // Finally erase this env variable
+ UnsetEnv(TC.name);
}
}
More information about the libcxx-commits
mailing list