Windows: qualify Configuration, Crypto and System
- Allowlist Configuration, Crypto and System for the Windows target. - System: link winmm for the Win32 audio backend; include windows.h before mmsystem.h. - Tests: add a whole-file // @requires-posix gate (CMake path and the VBS build.cpp) and mark the POSIX-only System suites; skip helper-based cases on Windows; make setenv/unsetenv and getpid portable. - The POSIX process helper is no longer built on Windows. Cross-built with x86_64-w64-mingw32 GCC 16.2: all modules and VoidTests.exe link. Linux System+Testing suite still passes (477 tests, 474 passed). Refs #65
This commit is contained in:
1 parent
c085822686
commit
bd5488b15b
16 files changed
+196
-31
No files matched your search
@@ -8,35 +8,57 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
namespace
|
||||
{
|
||||
// setenv/unsetenv are POSIX-only; _putenv_s is the Windows equivalent.
|
||||
void set_env(const char* name, const char* value)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
_putenv_s(name, value);
|
||||
#else
|
||||
::setenv(name, value, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void unset_env(const char* name)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
_putenv_s(name, "");
|
||||
#else
|
||||
::unsetenv(name);
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Void::Testing::Test get_env_finds_set_variable()
|
||||
{
|
||||
::setenv("VOID_TEST_VAR_A", "hello", 1);
|
||||
set_env("VOID_TEST_VAR_A", "hello");
|
||||
auto r = Void::Configuration::get_env("VOID_TEST_VAR_A");
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect_eq(*r, std::string{"hello"});
|
||||
::unsetenv("VOID_TEST_VAR_A");
|
||||
unset_env("VOID_TEST_VAR_A");
|
||||
}
|
||||
|
||||
Void::Testing::Test get_env_returns_error_for_missing()
|
||||
{
|
||||
::unsetenv("VOID_TEST_VAR_MISSING_XYZ");
|
||||
unset_env("VOID_TEST_VAR_MISSING_XYZ");
|
||||
auto r = Void::Configuration::get_env("VOID_TEST_VAR_MISSING_XYZ");
|
||||
Void::Testing::expect(!r.has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test get_env_or_returns_fallback_when_absent()
|
||||
{
|
||||
::unsetenv("VOID_TEST_VAR_MISSING_XYZ");
|
||||
unset_env("VOID_TEST_VAR_MISSING_XYZ");
|
||||
auto val = Void::Configuration::get_env_or("VOID_TEST_VAR_MISSING_XYZ", "default");
|
||||
Void::Testing::expect_eq(val, std::string{"default"});
|
||||
}
|
||||
|
||||
Void::Testing::Test get_env_or_returns_value_when_present()
|
||||
{
|
||||
::setenv("VOID_TEST_VAR_B", "world", 1);
|
||||
set_env("VOID_TEST_VAR_B", "world");
|
||||
auto val = Void::Configuration::get_env_or("VOID_TEST_VAR_B", "fallback");
|
||||
Void::Testing::expect_eq(val, std::string{"world"});
|
||||
::unsetenv("VOID_TEST_VAR_B");
|
||||
unset_env("VOID_TEST_VAR_B");
|
||||
}
|
||||
|
||||
Void::Testing::Test config_set_and_get()
|
||||
@@ -64,13 +86,13 @@ Void::Testing::Test config_get_or_returns_fallback()
|
||||
|
||||
Void::Testing::Test config_from_env_reads_listed_keys()
|
||||
{
|
||||
::setenv("VOID_TEST_CFG_X", "42", 1);
|
||||
::unsetenv("VOID_TEST_CFG_Y");
|
||||
set_env("VOID_TEST_CFG_X", "42");
|
||||
unset_env("VOID_TEST_CFG_Y");
|
||||
|
||||
auto cfg = Void::Configuration::Config::from_env({"VOID_TEST_CFG_X", "VOID_TEST_CFG_Y"});
|
||||
Void::Testing::expect_eq(cfg.size(), std::size_t{1});
|
||||
Void::Testing::expect_eq(std::string{cfg.get_or("VOID_TEST_CFG_X")}, std::string{"42"});
|
||||
::unsetenv("VOID_TEST_CFG_X");
|
||||
unset_env("VOID_TEST_CFG_X");
|
||||
}
|
||||
|
||||
Void::Testing::Test config_from_file_parses_key_value()
|
||||
|
||||
Reference in new issue
Block a user