From 49b14b2060b5dce569601a3821702d6b68967cc7 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Fri, 8 Mar 2024 13:45:23 -0500 Subject: [PATCH] Fix windows CI --- test/src/unit-cppapi-config.cc | 9 +-------- test/src/unit-curl.cc | 13 +++++-------- test/support/src/helpers.cc | 8 ++++++++ test/support/src/helpers.h | 9 +++++++++ 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/test/src/unit-cppapi-config.cc b/test/src/unit-cppapi-config.cc index 609ece4c7c0..7be58bb59d3 100644 --- a/test/src/unit-cppapi-config.cc +++ b/test/src/unit-cppapi-config.cc @@ -33,17 +33,10 @@ #include #include +#include "test/support/src/helpers.h" #include "tiledb/sm/c_api/tiledb_serialization.h" #include "tiledb/sm/cpp_api/tiledb" -int setenv_local(const char* __name, const char* __value) { -#ifdef _WIN32 - return _putenv_s(__name, __value); -#else - return ::setenv(__name, __value, 1); -#endif -} - TEST_CASE("C++ API: Config", "[cppapi][config]") { tiledb::Config config; config["foo"] = "bar"; diff --git a/test/src/unit-curl.cc b/test/src/unit-curl.cc index 6d0befd5aca..9241941ad2f 100644 --- a/test/src/unit-curl.cc +++ b/test/src/unit-curl.cc @@ -31,15 +31,12 @@ */ #include + +// clang-format off #include "test/support/src/helpers.h" -#include "tiledb/sm/rest/curl.h" #include "tiledb/sm/rest/rest_client.h" - -#ifdef _WIN32 -#include "tiledb/sm/filesystem/win.h" -#else -#include "tiledb/sm/filesystem/posix.h" -#endif +#include "tiledb/sm/rest/curl.h" // Must be included last to avoid Windows.h +// clang-format on #include #include @@ -106,7 +103,7 @@ TEST_CASE( cfg.set("rest.server_address", rest_server).ok(); } SECTION("rest.server_address set in environment") { - setenv("TILEDB_REST_SERVER_ADDRESS", rest_server.c_str(), 1); + setenv_local("TILEDB_REST_SERVER_ADDRESS", rest_server.c_str()); } SECTION("rest.server_address set by loaded config file") { std::string cfg_file = "tiledb_config.txt"; diff --git a/test/support/src/helpers.cc b/test/support/src/helpers.cc index 7f2789d8bb0..f7192213ad9 100644 --- a/test/support/src/helpers.cc +++ b/test/support/src/helpers.cc @@ -57,6 +57,14 @@ #include "tiledb/sm/serialization/array.h" #include "tiledb/sm/serialization/query.h" +int setenv_local(const char* __name, const char* __value) { +#ifdef _WIN32 + return _putenv_s(__name, __value); +#else + return ::setenv(__name, __value, 1); +#endif +} + std::mutex catch2_macro_mutex; namespace tiledb::test { diff --git a/test/support/src/helpers.h b/test/support/src/helpers.h index 283f536ea44..ddf3bc581a7 100644 --- a/test/support/src/helpers.h +++ b/test/support/src/helpers.h @@ -52,6 +52,15 @@ #include #include +/** + * Helper function to set environment variables across platforms. + * + * @param __name Name of the environment variable. + * @param __value Value of the environment variable. + * @return 0 on success, -1 on error. + */ +int setenv_local(const char* __name, const char* __value); + // A mutex for protecting the thread-unsafe Catch2 macros. extern std::mutex catch2_macro_mutex;