Skip to content

Commit

Permalink
Fix windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunrd0 committed Mar 8, 2024
1 parent 557214f commit 49b14b2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
9 changes: 1 addition & 8 deletions test/src/unit-cppapi-config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,10 @@
#include <thread>

#include <test/support/tdb_catch.h>
#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";
Expand Down
13 changes: 5 additions & 8 deletions test/src/unit-curl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@
*/

#include <test/support/tdb_catch.h>

// 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 <filesystem>
#include <fstream>
Expand Down Expand Up @@ -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";
Expand Down
8 changes: 8 additions & 0 deletions test/support/src/helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions test/support/src/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@
#include <string>
#include <thread>

/**
* 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;

Expand Down

0 comments on commit 49b14b2

Please sign in to comment.