[libcxx-commits] [PATCH] D98696: [libcxx] [test] Explicitly check that some env vars are ignored in the temp_dir_path test

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 19 00:34:03 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc9fc1a979cba: [libcxx] [test] Explicitly check that some env vars are ignored in the… (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D98696?vs=330942&id=331781#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98696/new/

https://reviews.llvm.org/D98696

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


Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
+++ libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
@@ -64,6 +64,14 @@
         {"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 @@
         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_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);
     }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98696.331781.patch
Type: text/x-patch
Size: 1582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210319/52ada98f/attachment.bin>


More information about the libcxx-commits mailing list