[libcxx-commits] [libcxx] 93671ff - [libcxx] [test] Use _putenv instead of setenv/unsetenv on windows
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 19 14:07:41 PDT 2020
Author: Martin Storsjö
Date: 2020-10-20T00:07:02+03:00
New Revision: 93671fffb5ef37060da54199cb9e009188f63a0e
URL: https://github.com/llvm/llvm-project/commit/93671fffb5ef37060da54199cb9e009188f63a0e
DIFF: https://github.com/llvm/llvm-project/commit/93671fffb5ef37060da54199cb9e009188f63a0e.diff
LOG: [libcxx] [test] Use _putenv instead of setenv/unsetenv on windows
Move the functions to the helper header and keep the arch specific
logic there.
Differential Revision: https://reviews.llvm.org/D89681
Added:
Modified:
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
libcxx/test/support/filesystem_test_helper.h
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 d9d25c8df138..a0b30e17128d 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
@@ -26,11 +26,11 @@
using namespace fs;
void PutEnv(std::string var, fs::path value) {
- assert(::setenv(var.c_str(), value.string().c_str(), /* overwrite */ 1) == 0);
+ assert(utils::setenv(var.c_str(), value.string().c_str(), /* overwrite */ 1) == 0);
}
void UnsetEnv(std::string var) {
- assert(::unsetenv(var.c_str()) == 0);
+ assert(utils::unsetenv(var.c_str()) == 0);
}
TEST_SUITE(filesystem_temp_directory_path_test_suite)
diff --git a/libcxx/test/support/filesystem_test_helper.h b/libcxx/test/support/filesystem_test_helper.h
index 37f0d6bcd367..704e2b26a0b4 100644
--- a/libcxx/test/support/filesystem_test_helper.h
+++ b/libcxx/test/support/filesystem_test_helper.h
@@ -45,11 +45,24 @@ namespace utils {
inline int link(const char *oldname, const char* newname) {
return !CreateHardLinkA(newname, oldname, NULL);
}
+ inline int setenv(const char *var, const char *val, int overwrite) {
+ (void)overwrite;
+ return ::_putenv((std::string(var) + "=" + std::string(val)).c_str());
+ }
+ inline int unsetenv(const char *var) {
+ return ::_putenv((std::string(var) + "=").c_str());
+ }
#else
using ::mkdir;
using ::ftruncate;
inline int symlink(const char* oldname, const char* newname, bool is_dir) { (void)is_dir; return ::symlink(oldname, newname); }
using ::link;
+ inline int setenv(const char *var, const char *val, int overwrite) {
+ return ::setenv(var, val, overwrite);
+ }
+ inline int unsetenv(const char *var) {
+ return ::unsetenv(var);
+ }
#endif
inline std::string getcwd() {
More information about the libcxx-commits
mailing list