From adb7b4effe7ad52a965bea5998d330c831c4a256 Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Sun, 6 Dec 2026 08:09:38 +0300 Subject: [PATCH] test: make the Windows-hosted suite portable - locate the vbs binary as vbs.exe on Windows (the .exe suffix was missing, so every test that spawns the CLI failed immediately); - skip the POSIX permission-bit assertion on Windows (ACLs); - skip the symlink checks when the host cannot create symlinks; - skip compiler-spawning tests under Wine, which cannot execute the Linux-hosted compiler from a Windows process. --- tests/CoreEngineTests.cpp | 35 ++++++++++++++++++++++++++++++++++- tests/FullV1Tests.cpp | 17 +++++++++++++---- tests/SelfHostTests.cpp | 17 +++++++++++++---- tests/SigningTests.cpp | 3 +++ 4 files changed, 63 insertions(+), 9 deletions(-) diff --git a/tests/CoreEngineTests.cpp b/tests/CoreEngineTests.cpp index ffb902a..73e5551 100644 --- a/tests/CoreEngineTests.cpp +++ b/tests/CoreEngineTests.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -27,8 +28,29 @@ #include #include +#if defined(_WIN32) +#include +#include +#endif + using namespace Void::Build; +namespace { +// Compiler-spawning tests need a native host: under Wine a Windows process +// cannot execute the Linux-hosted MinGW compiler. +bool host_can_exec_compiler() { +#if defined(_WIN32) + if (std::getenv("WINEPREFIX") != nullptr) { + return false; + } + const HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll"); + return ntdll == nullptr || ::GetProcAddress(ntdll, "wine_get_version") == nullptr; +#else + return true; +#endif +} +} // namespace + namespace { void write_text_file(const std::filesystem::path &path, std::string_view content) { @@ -234,7 +256,14 @@ VOID_TEST(CoreEngineTests, snapshot_content_mutations_symlinks_shadowing_and_iso Void::Testing::expect(fresh3.has_value() && !*fresh3); // 4. Symlink escape outside project root must be rejected. - std::filesystem::create_symlink(outside, proj / "src" / "escape.hpp"); + // Symlink creation needs a filesystem/host that supports it (Wine does not). + std::error_code link_ec; + std::filesystem::create_symlink(outside, proj / "src" / "escape.hpp", link_ec); + if (link_ec) { + std::printf("snapshot: symlinks unavailable (%s); skipping symlink checks\n", + link_ec.message().c_str()); + return; + } auto esc_snap = Snapshot::capture_snapshot(opts, {proj / "src" / "escape.hpp"}, {}); Void::Testing::expect(!esc_snap.has_value()); @@ -311,6 +340,10 @@ VOID_TEST(CoreEngineTests, state_store_cas_corruption_recovery_and_gc) { } VOID_TEST(CoreEngineTests, end_to_end_native_frontend_graph_execution_and_archive_member_removal) { + if (!host_can_exec_compiler()) { + std::printf("end-to-end compile skipped: the host cannot execute a native compiler\n"); + return; + } Void::FileSystem::TempDir tmp{"vbs_e2e_"}; const auto proj = tmp / "app_proj"; const auto build_dir = tmp / "build"; diff --git a/tests/FullV1Tests.cpp b/tests/FullV1Tests.cpp index e809c7d..f6e5e77 100644 --- a/tests/FullV1Tests.cpp +++ b/tests/FullV1Tests.cpp @@ -94,14 +94,23 @@ void write_raw_tar(const std::filesystem::path &tar_path, std::filesystem::path locate_vbs_binary() { std::error_code ec; + // Windows executables carry the .exe suffix. + const auto find_in = [&ec](const std::filesystem::path &dir) -> std::filesystem::path { + for (const auto *name : {"vbs", "vbs.exe"}) { + const auto candidate = dir / name; + if (std::filesystem::exists(candidate, ec)) { + return candidate; + } + } + return {}; + }; if (const auto self_exe = Platform::current_executable_path(); self_exe) { - const auto sibling = self_exe->parent_path() / "vbs"; - if (std::filesystem::exists(sibling, ec)) { - return sibling; + if (auto found = find_in(self_exe->parent_path()); !found.empty()) { + return found; } } if (!Bootstrap::binary_dir.empty()) { - return std::filesystem::path{Bootstrap::binary_dir} / "bin" / "vbs"; + return find_in(std::filesystem::path{Bootstrap::binary_dir} / "bin"); } return {}; } diff --git a/tests/SelfHostTests.cpp b/tests/SelfHostTests.cpp index 1ad867d..0930f20 100644 --- a/tests/SelfHostTests.cpp +++ b/tests/SelfHostTests.cpp @@ -43,14 +43,23 @@ std::filesystem::path locate_void_source_dir() { std::filesystem::path locate_vbs_binary() { std::error_code ec; + // Windows executables carry the .exe suffix. + const auto find_in = [&ec](const std::filesystem::path &dir) -> std::filesystem::path { + for (const auto *name : {"vbs", "vbs.exe"}) { + const auto candidate = dir / name; + if (std::filesystem::exists(candidate, ec)) { + return candidate; + } + } + return {}; + }; if (const auto self_exe = Platform::current_executable_path(); self_exe) { - const auto sibling = self_exe->parent_path() / "vbs"; - if (std::filesystem::exists(sibling, ec)) { - return sibling; + if (auto found = find_in(self_exe->parent_path()); !found.empty()) { + return found; } } if (!Bootstrap::binary_dir.empty()) { - return std::filesystem::path{Bootstrap::binary_dir} / "bin" / "vbs"; + return find_in(std::filesystem::path{Bootstrap::binary_dir} / "bin"); } return {}; } diff --git a/tests/SigningTests.cpp b/tests/SigningTests.cpp index f592407..5758fa0 100644 --- a/tests/SigningTests.cpp +++ b/tests/SigningTests.cpp @@ -84,7 +84,10 @@ VOID_TEST(Signing, seed_roundtrip_sign_verify_and_rejections) { const auto permissions = std::filesystem::status(seed_path).permissions(); Void::Testing::expect((permissions & Perms::owner_read) != Perms::none); Void::Testing::expect((permissions & Perms::owner_write) != Perms::none); +#if !defined(_WIN32) + // Windows filesystem permissions are ACL-based and not exposed as POSIX bits. Void::Testing::expect((permissions & (Perms::group_all | Perms::others_all)) == Perms::none); +#endif auto public_key = Provenance::public_key_from_seed(seed_path); Void::Testing::require(public_key.has_value());