feat: complete Track A zero-CMake self-hosting, full VOID_TEST migration, and bit-identical Stage 2/3 bootstrap
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 2s

This commit is contained in:
faumaray committed 2026-11-27 06:51:43 +03:00
1 parent fe0d1a6483
commit 5e1916dc5c
23 files changed
+945 -141

No files matched your search

+1 -6
View File
@@ -1,10 +1,9 @@
add_executable(vbs_sdk_tests SdkDeclarations.cpp ExampleContexts.cpp)
target_link_libraries(vbs_sdk_tests PRIVATE VoidBuild_ExampleDescription)
target_link_libraries(vbs_sdk_tests PRIVATE VoidBuild_ExampleDescription Void::Testing)
set_target_properties(vbs_sdk_tests PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
add_test(NAME vbs_sdk_tests COMMAND "${CMAKE_COMMAND}"
"-DSDK_TESTS=$<TARGET_FILE:vbs_sdk_tests>" -P "${CMAKE_CURRENT_SOURCE_DIR}/RunSdkTests.cmake")
void_add_tests(vbs_sdk_tests)
add_executable(vbs_core_tests CoreEngineTests.cpp)
target_include_directories(vbs_core_tests PRIVATE "${PROJECT_BINARY_DIR}/generated")
@@ -12,7 +11,6 @@ target_link_libraries(vbs_core_tests PRIVATE Void::BuildCore Void::Testing)
set_target_properties(vbs_core_tests PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
add_test(NAME vbs_core_tests COMMAND "$<TARGET_FILE:vbs_core_tests>" --no-color)
void_add_tests(vbs_core_tests)
add_executable(vbs_v1_tests FullV1Tests.cpp)
target_include_directories(vbs_v1_tests PRIVATE "${PROJECT_BINARY_DIR}/generated")
@@ -20,7 +18,6 @@ target_link_libraries(vbs_v1_tests PRIVATE Void::BuildCore Void::Testing)
set_target_properties(vbs_v1_tests PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
add_test(NAME vbs_v1_tests COMMAND "$<TARGET_FILE:vbs_v1_tests>" --no-color)
void_add_tests(vbs_v1_tests)
add_executable(vbs_registry_tests RegistryTests.cpp)
target_include_directories(vbs_registry_tests PRIVATE "${PROJECT_BINARY_DIR}/generated")
@@ -28,7 +25,6 @@ target_link_libraries(vbs_registry_tests PRIVATE Void::BuildRegistry Void::Testi
set_target_properties(vbs_registry_tests PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
add_test(NAME vbs_registry_tests COMMAND "$<TARGET_FILE:vbs_registry_tests>" --no-color)
void_add_tests(vbs_registry_tests)
add_executable(vbs_selfhost_tests SelfHostTests.cpp)
target_include_directories(vbs_selfhost_tests PRIVATE "${PROJECT_BINARY_DIR}/generated")
@@ -38,7 +34,6 @@ target_link_libraries(vbs_selfhost_tests PRIVATE Void::BuildCore Void::Testing)
set_target_properties(vbs_selfhost_tests PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
add_test(NAME vbs_selfhost_tests COMMAND "$<TARGET_FILE:vbs_selfhost_tests>" --no-color)
void_add_tests(vbs_selfhost_tests)
add_test(NAME vbs_sdk_registration COMMAND "${CMAKE_COMMAND}"
"-DSDK_TESTS=$<TARGET_FILE:vbs_sdk_tests>" -P "${CMAKE_CURRENT_SOURCE_DIR}/SdkRegistration.cmake")
+6 -6
View File
@@ -36,7 +36,7 @@ void write_text_file(const std::filesystem::path &path, std::string_view content
} // namespace
Void::Testing::Test sha256_nist_vectors_and_files() {
VOID_TEST(CoreEngineTests, sha256_nist_vectors_and_files) {
Void::Testing::expect_eq(
Util::sha256_hex(""),
std::string{"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"});
@@ -58,7 +58,7 @@ Void::Testing::Test sha256_nist_vectors_and_files() {
}
}
Void::Testing::Test process_supervisor_exec_failure_and_early_leader_grandchild_kill() {
VOID_TEST(CoreEngineTests, process_supervisor_exec_failure_and_early_leader_grandchild_kill) {
// 1. Distinguish exec failure from exit code 127.
{
Platform::ProcessRequest req;
@@ -108,7 +108,7 @@ Void::Testing::Test process_supervisor_exec_failure_and_early_leader_grandchild_
}
}
Void::Testing::Test profile_inheritance_and_cycle_rejection() {
VOID_TEST(CoreEngineTests, profile_inheritance_and_cycle_rejection) {
Profiles p = default_profiles();
p.inherit("debug-asan", "debug", {"-fno-omit-frame-pointer"});
auto resolved = p.resolve("debug-asan", CompilerFamily::Gcc, "Linux", "x86_64");
@@ -129,7 +129,7 @@ Void::Testing::Test profile_inheritance_and_cycle_rejection() {
[&] { (void)missing_parent.resolve("child", CompilerFamily::Gcc, "Linux", "x86_64"); });
}
Void::Testing::Test snapshot_content_mutations_symlinks_shadowing_and_isolation() {
VOID_TEST(CoreEngineTests, snapshot_content_mutations_symlinks_shadowing_and_isolation) {
Void::FileSystem::TempDir tmp{"vbs_snap_"};
const auto proj = tmp / "project";
const auto store = tmp / "store";
@@ -206,7 +206,7 @@ Void::Testing::Test snapshot_content_mutations_symlinks_shadowing_and_isolation(
Void::Testing::expect(!loop_snap.has_value());
}
Void::Testing::Test state_store_cas_corruption_recovery_and_gc() {
VOID_TEST(CoreEngineTests, state_store_cas_corruption_recovery_and_gc) {
Void::FileSystem::TempDir tmp{"vbs_state_"};
auto store = State::StateStore::open(tmp / ".vbs");
Void::Testing::expect(store.has_value());
@@ -262,7 +262,7 @@ Void::Testing::Test state_store_cas_corruption_recovery_and_gc() {
Void::Testing::expect(lookup.has_value() && !lookup->has_value());
}
Void::Testing::Test end_to_end_native_frontend_graph_execution_and_archive_member_removal() {
VOID_TEST(CoreEngineTests, end_to_end_native_frontend_graph_execution_and_archive_member_removal) {
Void::FileSystem::TempDir tmp{"vbs_e2e_"};
const auto proj = tmp / "app_proj";
const auto build_dir = tmp / "build";
+14 -2
View File
@@ -53,7 +53,19 @@ foreach(profile IN ITEMS debug release)
expect_json(executable targets 5 kind)
expect_json(vbs_self_smoke targets 6 name)
expect_json(test targets 6 kind)
foreach(index IN ITEMS 0 1 3 4 5 6)
expect_json(vbs_benchmarks targets 7 name)
expect_json(executable targets 7 kind)
expect_json(vbs_sdk_tests targets 8 name)
expect_json(test targets 8 kind)
expect_json(vbs_core_tests targets 9 name)
expect_json(test targets 9 kind)
expect_json(vbs_v1_tests targets 10 name)
expect_json(test targets 10 kind)
expect_json(vbs_registry_tests targets 11 name)
expect_json(test targets 11 kind)
expect_json(vbs_selfhost_tests targets 12 name)
expect_json(test targets 12 kind)
foreach(index IN ITEMS 0 1 3 4 5 6 7 8 9 10 11 12)
if(compiler STREQUAL "gcc")
expect_json(-Wduplicated-cond targets "${index}" compile_options 2)
else()
@@ -62,7 +74,7 @@ foreach(profile IN ITEMS debug release)
endforeach()
expect_json(git dependencies 0 source kind)
expect_json(3e254055e081a104f08df68dde39711bc7813518 dependencies 0 source revision)
expect_json(cmake dependencies 0 builder)
expect_json(native dependencies 0 builder)
string(JSON option_type TYPE "${graph}" dependencies 0 options BUILD_SHARED_LIBS)
if(NOT option_type STREQUAL "BOOLEAN")
message(FATAL_ERROR "CMake bool option lost its type")
+12 -5
View File
@@ -4,7 +4,7 @@
#include <algorithm>
Void::Testing::Test example_uses_runtime_compiler() {
VOID_TEST(ExampleContexts, example_uses_runtime_compiler) {
Void::Build::Profiles definitions;
profiles(definitions);
Void::Build::Project gcc{
@@ -29,7 +29,7 @@ Void::Testing::Test example_uses_runtime_compiler() {
}
}
Void::Testing::Test example_profile_options_are_separate() {
VOID_TEST(ExampleContexts, example_profile_options_are_separate) {
Void::Build::Profiles definitions;
profiles(definitions);
Void::Build::Project debug{
@@ -47,11 +47,11 @@ Void::Testing::Test example_profile_options_are_separate() {
Void::Testing::expect(debug.to_json() != release.to_json());
}
Void::Testing::Test example_records_sources_links_and_pin() {
VOID_TEST(ExampleContexts, example_records_sources_links_and_pin) {
Void::Build::Project project{Void::Build::default_profiles().resolve(
"debug", Void::Build::CompilerFamily::Gcc, "linux", "x86_64")};
build(project);
Void::Testing::expect_eq(project.targets().size(), std::size_t{7});
Void::Testing::expect_eq(project.targets().size(), std::size_t{13});
Void::Testing::expect_eq(project.targets().at(0).name, std::string{"VoidBuildSdk"});
Void::Testing::expect_eq(project.targets().at(0).sources.at(0).path,
std::string{"src/Build.cpp"});
@@ -68,7 +68,14 @@ Void::Testing::Test example_records_sources_links_and_pin() {
Void::Testing::expect_eq(project.targets().at(5).name, std::string{"vbs-registry"});
Void::Testing::expect_eq(project.targets().at(6).name, std::string{"vbs_self_smoke"});
Void::Testing::expect_eq(project.targets().at(6).kind, Void::Build::TargetKind::Test);
Void::Testing::expect_eq(project.targets().at(7).name, std::string{"vbs_benchmarks"});
Void::Testing::expect_eq(project.targets().at(8).name, std::string{"vbs_sdk_tests"});
Void::Testing::expect_eq(project.targets().at(8).kind, Void::Build::TargetKind::Test);
Void::Testing::expect_eq(project.targets().at(9).name, std::string{"vbs_core_tests"});
Void::Testing::expect_eq(project.targets().at(10).name, std::string{"vbs_v1_tests"});
Void::Testing::expect_eq(project.targets().at(11).name, std::string{"vbs_registry_tests"});
Void::Testing::expect_eq(project.targets().at(12).name, std::string{"vbs_selfhost_tests"});
Void::Testing::expect_eq(project.dependencies().at(0).revision,
std::string{"3e254055e081a104f08df68dde39711bc7813518"});
Void::Testing::expect_eq(project.dependencies().at(0).builder, std::string{"cmake"});
Void::Testing::expect_eq(project.dependencies().at(0).builder, std::string{"native"});
}
+102 -15
View File
@@ -83,10 +83,25 @@ void write_raw_tar(const std::filesystem::path &tar_path,
out.write(end.data(), 1024);
}
std::filesystem::path locate_vbs_binary() {
std::error_code ec;
if (const auto self = std::filesystem::read_symlink("/proc/self/exe", ec);
!ec && !self.empty()) {
const auto sibling = self.parent_path() / "vbs";
if (std::filesystem::exists(sibling, ec)) {
return sibling;
}
}
if (!Bootstrap::binary_dir.empty()) {
return std::filesystem::path{Bootstrap::binary_dir} / "bin" / "vbs";
}
return {};
}
} // namespace
// === Plan 09: CompDB projection, selection ticket races, user-file preservation, recovery ===
Void::Testing::Test compdb_projection_ticket_races_and_user_file_preservation() {
VOID_TEST(FullV1Tests, compdb_projection_ticket_races_and_user_file_preservation) {
Void::FileSystem::TempDir tmp{"vbs_compdb_"};
const auto proj = tmp / "proj";
const auto build_dir = tmp / "build";
@@ -193,7 +208,7 @@ Void::Testing::Test compdb_projection_ticket_races_and_user_file_preservation()
}
// === Plan 10: Inotify watcher + strict MetadataOnly watch boundary ===
Void::Testing::Test watcher_inotify_and_metadata_only_forbids_foreign_configure() {
VOID_TEST(FullV1Tests, watcher_inotify_and_metadata_only_forbids_foreign_configure) {
Void::FileSystem::TempDir tmp{"vbs_watch_"};
const auto proj = tmp / "proj";
const auto build_dir = tmp / "build";
@@ -246,7 +261,7 @@ void build(Void::Build::Project &p) {
}
// === Plan 11: TOML 1.0, PubGrub solver (with exhaustive oracle), atomic CAS lockfile ===
Void::Testing::Test toml_solver_oracle_and_atomic_cas_lockfile() {
VOID_TEST(FullV1Tests, toml_solver_oracle_and_atomic_cas_lockfile) {
Void::FileSystem::TempDir tmp{"vbs_pkg_"};
const auto toml_file = tmp / "vbs.deps.toml";
write_file(toml_file, R"toml(
@@ -385,7 +400,7 @@ features = ["header-only"]
}
// === Plan 12: Deterministic tar, malicious archive security, binary ABI matching, redaction ===
Void::Testing::Test archive_security_determinism_binary_abi_and_redaction() {
VOID_TEST(FullV1Tests, archive_security_determinism_binary_abi_and_redaction) {
Void::FileSystem::TempDir tmp{"vbs_arc_"};
const auto proj = tmp / "pkg_src";
write_file(proj / "build.cpp", "void build(Void::Build::Project&) {}\n");
@@ -443,7 +458,7 @@ Void::Testing::Test archive_security_determinism_binary_abi_and_redaction() {
// === Plan 13, 14, 15: Real CMake provider, Meson provider, VbsDeps.cmake bridge, Install/Relocate
// ===
Void::Testing::Test foreign_cmake_meson_providers_bridge_and_relocatable_install() {
VOID_TEST(FullV1Tests, foreign_cmake_meson_providers_bridge_and_relocatable_install) {
Void::FileSystem::TempDir tmp{"vbs_foreign_"};
auto ctx = default_profiles().resolve("debug", CompilerFamily::Gcc, Toolchain::host_os_name(),
Toolchain::host_architecture_name());
@@ -615,10 +630,11 @@ static_library('m_helper', 'src/helper.cpp', include_directories: inc)
Void::Testing::expect(!std::filesystem::exists(prefix_b / "lib" / "libwrap.a"));
// 5. Real CMake Bridge (VbsDeps.cmake) consumer test!
const auto vbs_bin = std::filesystem::path{Bootstrap::binary_dir} / "bin" / "vbs";
const auto vbs_bin = locate_vbs_binary();
const auto bridge_module =
std::filesystem::path{Bootstrap::source_dir} / "cmake" / "bridge" / "VbsDeps.cmake";
if (std::filesystem::exists(vbs_bin) && Platform::resolve_executable("cmake").has_value()) {
if (!vbs_bin.empty() && std::filesystem::exists(vbs_bin) &&
Platform::resolve_executable("cmake").has_value()) {
const auto br_proj = tmp / "bridge_consumer";
write_file(br_proj / "CMakeLists.txt",
"cmake_minimum_required(VERSION 4.0)\n"
@@ -691,7 +707,7 @@ void build(Void::Build::Project &p) {
// === Plan 08: Modern C++ (GCC16 P1689 named modules + partitions, cycle/dup checks, unity, PCH)
// ===
Void::Testing::Test modern_cpp_modules_scan_collation_cycles_and_unity_exclusion() {
VOID_TEST(FullV1Tests, modern_cpp_modules_scan_collation_cycles_and_unity_exclusion) {
Void::FileSystem::TempDir tmp{"vbs_mod_"};
auto ctx = default_profiles().resolve("debug", CompilerFamily::Gcc, Toolchain::host_os_name(),
Toolchain::host_architecture_name());
@@ -797,7 +813,7 @@ Void::Testing::Test modern_cpp_modules_scan_collation_cycles_and_unity_exclusion
}
// === Plan 04/08/19 Matrix: Clang 23 target toolchain probe, build, and P1689 module scan ===
Void::Testing::Test clang23_target_toolchain_and_p1689_module_scan() {
VOID_TEST(FullV1Tests, clang23_target_toolchain_and_p1689_module_scan) {
if (!Platform::resolve_executable("clang++").has_value()) {
return; // Only skip if Clang is genuinely absent from PATH.
}
@@ -899,7 +915,7 @@ Void::Testing::Test clang23_target_toolchain_and_p1689_module_scan() {
}
// === Plan 08 Full Graph Integration: Modules+Partitions, Unity+PerFile, HeaderUnit, Sanitizers ===
Void::Testing::Test graph_lowering_modules_partitions_unity_header_units_and_sanitizers() {
VOID_TEST(FullV1Tests, graph_lowering_modules_partitions_unity_header_units_and_sanitizers) {
Void::FileSystem::TempDir tmp{"vbs_plan08_"};
auto ctx = default_profiles().resolve("debug", CompilerFamily::Gcc, Toolchain::host_os_name(),
Toolchain::host_architecture_name());
@@ -1057,7 +1073,7 @@ Void::Testing::Test graph_lowering_modules_partitions_unity_header_units_and_san
// === Plan 20 Slice 1: Bounded native CMake graph translation, equivalence, mutations & fallback
// ===
Void::Testing::Test plan20_bounded_cmake_translation_equivalence_mutations_and_fallback() {
VOID_TEST(FullV1Tests, plan20_bounded_cmake_translation_equivalence_mutations_and_fallback) {
Void::FileSystem::TempDir tmp{"vbs_plan20_"};
auto ctx = default_profiles().resolve("debug", CompilerFamily::Gcc, Toolchain::host_os_name(),
Toolchain::host_architecture_name());
@@ -1217,7 +1233,7 @@ target_include_directories(p20_genlib PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
// === Plan 20 Slice 2A: Bounded native Meson graph translation + unsupported custom_target fallback
// ===
Void::Testing::Test plan20_bounded_meson_translation_equivalence_and_fallback() {
VOID_TEST(FullV1Tests, plan20_bounded_meson_translation_equivalence_and_fallback) {
if (!Platform::resolve_executable("meson").has_value()) {
return;
}
@@ -1332,9 +1348,9 @@ static_library('mgenlib', ['src/gen.cpp', gen])
}
// === Wave 8 DX CLI: vbs init -> vbs test -> vbs graph -> vbs doctor -> vbs clean ===
Void::Testing::Test cli_init_graph_clean_doctor_end_to_end() {
const auto vbs_bin = std::filesystem::path{Bootstrap::binary_dir} / "bin" / "vbs";
if (!std::filesystem::exists(vbs_bin)) {
VOID_TEST(FullV1Tests, cli_init_graph_clean_doctor_end_to_end) {
const auto vbs_bin = locate_vbs_binary();
if (vbs_bin.empty() || !std::filesystem::exists(vbs_bin)) {
return;
}
Void::FileSystem::TempDir tmp{"vbs_dx_"};
@@ -1399,3 +1415,74 @@ Void::Testing::Test cli_init_graph_clean_doctor_end_to_end() {
Void::Testing::expect(r_clean_all.has_value() && r_clean_all->succeeded());
Void::Testing::expect(!std::filesystem::exists(bdir));
}
// === Track A1: Native VBS subproject dependency (builder == "native", zero CMake!) ===
VOID_TEST(FullV1Tests, native_vbs_subproject_dependency_builds_without_cmake) {
const auto vbs_bin = locate_vbs_binary();
Void::Testing::expect(!vbs_bin.empty() && std::filesystem::exists(vbs_bin));
if (vbs_bin.empty() || !std::filesystem::exists(vbs_bin)) {
return;
}
Void::FileSystem::TempDir tmp{"vbs_native_subproj_"};
const auto trap_bin = tmp / "trap_bin";
write_file(trap_bin / "cmake",
"#!/bin/sh\necho 'FORBIDDEN CMAKE INVOCATION IN NATIVE DEP BUILD' >&2\nexit 99\n");
std::filesystem::permissions(trap_bin / "cmake", std::filesystem::perms::owner_exec |
std::filesystem::perms::owner_read |
std::filesystem::perms::owner_write |
std::filesystem::perms::group_exec |
std::filesystem::perms::others_exec);
std::string trapped_path = trap_bin.string();
if (const char *old_path = std::getenv("PATH")) {
trapped_path += ":";
trapped_path += old_path;
}
// Pure `build.cpp` library dependency (NO CMakeLists.txt!).
const auto dep_dir = tmp / "sub_math_dep";
write_file(dep_dir / "build.cpp", R"cpp(#include <Void/Build.hpp>
void build(Void::Build::Project &p) {
auto lib = p.static_library("sub_math");
lib.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"src/math.cpp"})
.include_directory("include", Void::Build::Visibility::Public);
}
)cpp");
write_file(dep_dir / "include" / "sub_math.hpp", "#pragma once\nint sub_math_answer();\n");
write_file(dep_dir / "src" / "math.cpp",
"#include \"sub_math.hpp\"\nint sub_math_answer() { return 42; }\n");
const auto cons_dir = tmp / "consumer";
const auto cons_build = tmp / "consumer_build";
write_file(cons_dir / "build.cpp",
"#include <Void/Build.hpp>\n"
"void build(Void::Build::Project &p) {\n"
" auto dep = p.dependency(\"math\").path(\"" +
dep_dir.string() +
"\").native_builder();\n"
" p.test(\"consumer_test\")\n"
" .cxx_standard(Void::Build::CxxStandard::Cxx26)\n"
" .sources({\"tests/main.cpp\"})\n"
" .link(dep.target(\"sub_math\"));\n"
"}\n");
write_file(
cons_dir / "tests" / "main.cpp",
"#include \"sub_math.hpp\"\nint main() { return sub_math_answer() == 42 ? 0 : 1; }\n");
Platform::ProcessRequest req;
req.executable = vbs_bin;
req.arguments = {"test", "--project", cons_dir.string(), "--build-dir", cons_build.string()};
req.environment.set_vars["PATH"] = trapped_path;
req.timeout = std::chrono::seconds{120};
auto res = Platform::run_supervised(req);
Void::Testing::expect_eq(
res ? (res->succeeded() ? std::string{} : (res->stdout_data + res->stderr_data))
: res.error().message(),
std::string{});
Void::Testing::expect(res.has_value() && res->succeeded());
if (res) {
Void::Testing::expect(res->stdout_data.find("PASSED 'consumer_test'") != std::string::npos);
}
}
+20 -5
View File
@@ -43,9 +43,24 @@ std::string extract_json_str(std::string_view json, const std::string &key) {
return s ? *s : std::string{};
}
std::filesystem::path locate_vbs_binary() {
std::error_code ec;
if (const auto self = std::filesystem::read_symlink("/proc/self/exe", ec);
!ec && !self.empty()) {
const auto sibling = self.parent_path() / "vbs";
if (std::filesystem::exists(sibling, ec)) {
return sibling;
}
}
if (!Bootstrap::binary_dir.empty()) {
return std::filesystem::path{Bootstrap::binary_dir} / "bin" / "vbs";
}
return {};
}
} // namespace
Void::Testing::Test registry_rbac_immutability_csrf_xss_web_and_backup_restore() {
VOID_TEST(RegistryTests, registry_rbac_immutability_csrf_xss_web_and_backup_restore) {
Void::FileSystem::TempDir tmp{"vbs_reg_"};
RegistryConfig cfg;
cfg.data_dir = tmp / "data";
@@ -202,10 +217,10 @@ Void::Testing::Test registry_rbac_immutability_csrf_xss_web_and_backup_restore()
// End-to-end live client <-> server test: `vbs publish` -> `vbs deps resolve` -> `vbs build
// --locked`!
Void::Testing::Test cli_publish_deps_resolve_and_locked_build_against_live_registry() {
const auto vbs_bin = std::filesystem::path{Bootstrap::binary_dir} / "bin" / "vbs";
Void::Testing::expect(std::filesystem::exists(vbs_bin));
if (!std::filesystem::exists(vbs_bin)) {
VOID_TEST(RegistryTests, cli_publish_deps_resolve_and_locked_build_against_live_registry) {
const auto vbs_bin = locate_vbs_binary();
Void::Testing::expect(!vbs_bin.empty() && std::filesystem::exists(vbs_bin));
if (vbs_bin.empty() || !std::filesystem::exists(vbs_bin)) {
return;
}
+14 -14
View File
@@ -23,7 +23,7 @@ const Json &element(const Json &value, std::size_t index) {
std::string text(const Json &value) { return std::get<std::string>(value.value); }
} // namespace
Void::Testing::Test default_profiles_and_overrides() {
VOID_TEST(SdkDeclarations, default_profiles_and_overrides) {
const auto profiles = Void::Build::default_profiles();
const auto debug =
profiles.resolve("debug", Void::Build::CompilerFamily::Clang, "linux", "aarch64");
@@ -36,7 +36,7 @@ Void::Testing::Test default_profiles_and_overrides() {
Void::Testing::expect_eq(release.compile_options.at(0), std::string{"-O3"});
}
Void::Testing::Test rejects_invalid_profiles() {
VOID_TEST(SdkDeclarations, rejects_invalid_profiles) {
auto profiles = Void::Build::default_profiles();
Void::Testing::expect_throw<std::invalid_argument>([&] { profiles.add("debug"); });
Void::Testing::expect_throw<std::invalid_argument>([&] { profiles.add(""); });
@@ -50,7 +50,7 @@ Void::Testing::Test rejects_invalid_profiles() {
[&] { (void)profiles.resolve("debug", Void::Build::CompilerFamily::Gcc, "", "x86_64"); });
}
Void::Testing::Test declaration_records_and_visibility() {
VOID_TEST(SdkDeclarations, declaration_records_and_visibility) {
Void::Build::Project project{context()};
auto library = project.static_library("library");
library.sources({"one.cpp", "two.cpp"})
@@ -68,7 +68,7 @@ Void::Testing::Test declaration_records_and_visibility() {
Void::Build::Visibility::Interface);
}
Void::Testing::Test sources_are_symbolic() {
VOID_TEST(SdkDeclarations, sources_are_symbolic) {
Void::Build::Project project{context()};
auto target = project.executable("symbolic");
target.sources({"missing/../literal.cpp"}).sources(project.glob("nonexistent/**/*.cpp"));
@@ -80,7 +80,7 @@ Void::Testing::Test sources_are_symbolic() {
std::string{"nonexistent/**/*.cpp"});
}
Void::Testing::Test handles_survive_record_growth() {
VOID_TEST(SdkDeclarations, handles_survive_record_growth) {
Void::Build::Project project{context()};
auto library = project.static_library("first");
auto dependency = project.dependency("original");
@@ -100,7 +100,7 @@ Void::Testing::Test handles_survive_record_growth() {
Void::Testing::expect_eq(project.dependencies().front().revision, std::string{revision});
}
Void::Testing::Test rejects_cross_project_links() {
VOID_TEST(SdkDeclarations, rejects_cross_project_links) {
Void::Build::Project first{context()};
Void::Build::Project second{context()};
auto app = first.executable("app");
@@ -111,7 +111,7 @@ Void::Testing::Test rejects_cross_project_links() {
Void::Testing::expect(app.record().links.empty());
}
Void::Testing::Test rejects_expired_handles_and_owner_moves() {
VOID_TEST(SdkDeclarations, rejects_expired_handles_and_owner_moves) {
static_assert(!std::is_move_constructible_v<Void::Build::Project>);
static_assert(!std::is_copy_constructible_v<Void::Build::Project>);
std::optional<Void::Build::Target> target;
@@ -132,7 +132,7 @@ Void::Testing::Test rejects_expired_handles_and_owner_moves() {
Void::Testing::expect_throw<std::logic_error>([&] { app.link(*imported); });
}
Void::Testing::Test rejects_empty_and_duplicate_identifiers() {
VOID_TEST(SdkDeclarations, rejects_empty_and_duplicate_identifiers) {
Void::Build::Project project{context()};
auto app = project.executable("app");
auto dep = project.dependency("dep");
@@ -149,7 +149,7 @@ Void::Testing::Test rejects_empty_and_duplicate_identifiers() {
Void::Testing::expect_throw<std::invalid_argument>([&] { (void)project.glob(""); });
}
Void::Testing::Test rejects_contradictory_providers() {
VOID_TEST(SdkDeclarations, rejects_contradictory_providers) {
Void::Build::Project project{context()};
auto git = project.dependency("git");
git.git("https://example.invalid/repo", Void::Build::Commit{revision}).cmake();
@@ -170,7 +170,7 @@ Void::Testing::Test rejects_contradictory_providers() {
Void::Testing::expect_throw<std::invalid_argument>([&] { (void)project.to_json(); });
}
Void::Testing::Test json_schema_types_and_escaping() {
VOID_TEST(SdkDeclarations, json_schema_types_and_escaping) {
Void::Build::Project project{context()};
std::string escaped = "quote\" slash\\ newline\n\r\t";
for (char c = 0; c < 32; ++c)
@@ -218,7 +218,7 @@ Void::Testing::Test json_schema_types_and_escaping() {
std::string{"org/pkg"});
}
Void::Testing::Test json_preserves_valid_utf8() {
VOID_TEST(SdkDeclarations, json_preserves_valid_utf8) {
// Boundary scalar values for every UTF-8 width, including either side of surrogates.
const std::string unicode = "ASCII \xc2\x80\xdf\xbf\xe0\xa0\x80\xed\x9f\xbf"
"\xee\x80\x80\xef\xbf\xbf\xf0\x90\x80\x80\xf4\x8f\xbf\xbf";
@@ -240,7 +240,7 @@ Void::Testing::Test json_preserves_valid_utf8() {
Void::Testing::expect_eq(text(member(options, unicode)), unicode);
}
Void::Testing::Test json_rejects_malformed_utf8() {
VOID_TEST(SdkDeclarations, json_rejects_malformed_utf8) {
const std::vector<std::string> invalid{
"\x80", "\xbf", "\xc0\x80", "\xc1\xbf", "\xc2",
"\xc2 ", "\xe0\x80\x80", "\xe0\x9f\xbf", "\xe1\x80", "\xe1 \x80",
@@ -276,7 +276,7 @@ Void::Testing::Test json_rejects_malformed_utf8() {
}
}
Void::Testing::Test independent_projects_and_contexts() {
VOID_TEST(SdkDeclarations, independent_projects_and_contexts) {
auto initial = context();
Void::Build::Project first{initial};
initial.name = "mutated";
@@ -289,7 +289,7 @@ Void::Testing::Test independent_projects_and_contexts() {
Void::Testing::expect(first.to_json() != second.to_json());
}
Void::Testing::Test rejects_option_errors_without_mutation() {
VOID_TEST(SdkDeclarations, rejects_option_errors_without_mutation) {
Void::Build::Project project{context()};
auto dep = project.dependency("library");
Void::Testing::expect_throw<std::invalid_argument>([&] { dep.cmake({{"", true}}); });
+156 -13
View File
@@ -9,6 +9,8 @@
#include <Void/Build/SelfHost/TestRegistryGen.hpp>
#include <Void/Build/State/StateStore.hpp>
#include <Void/Build/Toolchain/Driver.hpp>
#include <Void/Build/Util/Sha256.hpp>
#include <Void/Configuration/Env.hpp>
#include <Void/System/TempDir.hpp>
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Test.hpp>
@@ -25,10 +27,38 @@ void write_file(const std::filesystem::path &path, std::string_view content) {
auto r = Platform::atomic_write_file(path, content, false);
Void::Testing::expect(r.has_value());
}
std::filesystem::path locate_void_source_dir() {
if (auto env = Void::Configuration::get_env("VBS_VOID_SOURCE_DIR");
env && !env->empty() && std::filesystem::is_directory(*env)) {
return std::filesystem::path{*env};
}
#ifdef VBS_VOID_SOURCE_PATH
if (std::filesystem::is_directory(std::filesystem::path{VBS_VOID_SOURCE_PATH})) {
return std::filesystem::path{VBS_VOID_SOURCE_PATH};
}
#endif
return std::filesystem::path{Bootstrap::source_dir} / "build" / "voidlibrary-pinned";
}
std::filesystem::path locate_vbs_binary() {
std::error_code ec;
if (const auto self = std::filesystem::read_symlink("/proc/self/exe", ec);
!ec && !self.empty()) {
const auto sibling = self.parent_path() / "vbs";
if (std::filesystem::exists(sibling, ec)) {
return sibling;
}
}
if (!Bootstrap::binary_dir.empty()) {
return std::filesystem::path{Bootstrap::binary_dir} / "bin" / "vbs";
}
return {};
}
} // namespace
// Plan 18: Native non-CMake Void::Testing scanner avoids equal-basename collisions!
Void::Testing::Test native_test_registration_generator_avoids_basename_collisions() {
VOID_TEST(SelfHostTests, native_test_registration_generator_avoids_basename_collisions) {
Void::FileSystem::TempDir tmp{"vbs_testgen_"};
const auto f1 = tmp / "dir_a" / "SameStem.cpp";
const auto f2 = tmp / "dir_b" / "SameStem.cpp";
@@ -50,8 +80,8 @@ Void::Testing::Test native_test_registration_generator_avoids_basename_collision
// Plan 18: Strict native VoidLibrary closure + native VBS SDK + native test runner built
// completely WITHOUT CMake (trapped cmake shim ahead of PATH!) in a clean stage directory!
Void::Testing::Test strict_native_selfhost_voidlibrary_and_sdk_without_cmake() {
const std::filesystem::path void_src{VBS_VOID_SOURCE_PATH};
VOID_TEST(SelfHostTests, strict_native_selfhost_voidlibrary_and_sdk_without_cmake) {
const auto void_src = locate_void_source_dir();
Void::Testing::expect(std::filesystem::is_directory(void_src));
Void::FileSystem::TempDir tmp{"vbs_selfhost_"};
@@ -85,17 +115,13 @@ Void::Testing::Test strict_native_selfhost_voidlibrary_and_sdk_without_cmake() {
.include_directory((vbs_root / "include").string(), Visibility::Public)
.compile_option("-freflection", Visibility::Public);
// Generate native C++ test registrations for SdkDeclarations.cpp (NO CMake scanner!).
// Compile self-registering VL-009 VOID_TEST suite SdkDeclarations.cpp directly (zero CMake,
// zero external test scanner!).
const auto test_src = vbs_root / "tests" / "SdkDeclarations.cpp";
auto reg = SelfHost::generate_test_registration_unit(test_src, stage1_dir / "gen_tests");
Void::Testing::expect(reg.has_value() && reg->cases.size() >= 14);
if (!reg)
return;
auto native_tests = proj.executable("stage1_sdk_tests");
native_tests.cxx_standard(CxxStandard::Cxx26)
.sources(SourceSet::file(test_src.string()))
.sources(SourceSet::file(reg->generated_cpp.string()))
.link(sdk)
.link(void_libs.modules.at("Testing"))
.link(void_libs.modules.at("Data"));
@@ -230,8 +256,8 @@ int main() {
// VoidBuildSdk + VoidBuildCore + stage-isolated BootstrapConfig.hpp, ZERO CMake!) into stage1_dir,
// then executes that freshly self-hosted `stage1/bin/vbs` binary WITH TRAPPED `cmake` ON PATH to
// build and test a real Stage 2 C++ project!
Void::Testing::Test strict_native_full_vbs_stage1_to_stage2_without_cmake() {
const std::filesystem::path void_src{VBS_VOID_SOURCE_PATH};
VOID_TEST(SelfHostTests, strict_native_full_vbs_stage1_to_stage2_without_cmake) {
const auto void_src = locate_void_source_dir();
const std::filesystem::path vbs_root{Bootstrap::source_dir};
Void::Testing::expect(std::filesystem::is_directory(void_src));
@@ -342,8 +368,8 @@ void build(Void::Build::Project &p) {
// VL-009: Verify VoidLibrary's upstream self-registering `VOID_TEST(suite, name)` macro works
// purely with `g++` (zero CMake AND zero external scanner) including equal-basename files!
Void::Testing::Test native_void_test_macro_zero_cmake_and_basename_collisions() {
const std::filesystem::path void_src{VBS_VOID_SOURCE_PATH};
VOID_TEST(SelfHostTests, native_void_test_macro_zero_cmake_and_basename_collisions) {
const auto void_src = locate_void_source_dir();
Void::Testing::expect(std::filesystem::is_directory(void_src));
Void::FileSystem::TempDir tmp{"vbs_vl009_"};
@@ -434,3 +460,120 @@ VOID_TEST(BetaSuite, multiplication_works) {
Void::Testing::expect(ran->stdout_data.find("2 tests:") != std::string::npos);
}
}
// Track A3: Reproducible bit-identical artifacts across distinct build directories!
VOID_TEST(SelfHostTests, reproducible_stage2_equals_stage3_artifacts_across_build_dirs) {
const auto vbs_bin = locate_vbs_binary();
Void::Testing::expect(!vbs_bin.empty() && std::filesystem::exists(vbs_bin));
if (vbs_bin.empty() || !std::filesystem::exists(vbs_bin)) {
return;
}
Void::FileSystem::TempDir tmp{"vbs_repro_"};
const auto trap_bin = tmp / "trap_bin";
write_file(trap_bin / "cmake",
"#!/bin/sh\necho 'FORBIDDEN CMAKE INVOCATION IN REPRO STAGE' >&2\nexit 99\n");
(void)::chmod((trap_bin / "cmake").c_str(), 0755);
std::string trapped_path = trap_bin.string();
if (const char *old_path = std::getenv("PATH")) {
trapped_path += ":";
trapped_path += old_path;
}
const auto proj = tmp / "repro_proj";
write_file(proj / "build.profiles.cpp", R"cpp(#include <Void/Build.hpp>
void profiles(Void::Build::Profiles &p) {
Void::Build::ProfileDescription d;
d.name = "debug";
d.compile_options = {"-O0", "-g"};
d.reproducibility_epoch = 1700000000;
p.define(std::move(d));
}
)cpp");
write_file(proj / "build.cpp", R"cpp(#include <Void/Build.hpp>
void build(Void::Build::Project &p) {
auto gen = p.custom_action("gen_ver");
gen.command({"/bin/sh", "-c",
"mkdir -p \"$GEN\" && printf '#pragma once\\ninline constexpr int kVer = 7;\\n' "
"> \"$GEN/gen_ver.hpp\""})
.outputs({"gen_ver.hpp"});
auto lib = p.static_library("repro_lib");
lib.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"src/lib.cpp"})
.include_directory("include", Void::Build::Visibility::Public);
auto app = p.executable("repro_app");
app.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"src/main.cpp"})
.depends_on(gen)
.include_directory("$GEN/", Void::Build::Visibility::Private)
.link(lib);
}
)cpp");
write_file(proj / "include" / "repro.hpp", "#pragma once\nint repro_fn();\n");
write_file(proj / "src" / "lib.cpp", R"cpp(#include "repro.hpp"
namespace {
int local_helper() { return 35; }
struct AutoInit { int v{local_helper()}; };
const AutoInit g_init{};
} // namespace
int repro_fn() { return g_init.v; }
)cpp");
write_file(proj / "src" / "main.cpp", R"cpp(#include "repro.hpp"
#include "gen_ver.hpp"
#include <iostream>
int main() {
std::cout << (repro_fn() + kVer) << "|" << __DATE__ << "|" << __FILE__ << "\n";
return 0;
}
)cpp");
const auto stage_a = tmp / "stage_a";
const auto stage_b = tmp / "stage_b";
auto build_stage = [&](const std::filesystem::path &bdir) {
Platform::ProcessRequest req;
req.executable = vbs_bin;
req.arguments = {"build", "--project", proj.string(), "--build-dir",
bdir.string(), "--profile", "debug", "--no-cache"};
req.environment.set_vars["PATH"] = trapped_path;
req.timeout = std::chrono::seconds{120};
return Platform::run_supervised(req);
};
auto ra = build_stage(stage_a);
auto rb = build_stage(stage_b);
Void::Testing::expect(ra.has_value() && ra->succeeded());
Void::Testing::expect(rb.has_value() && rb->succeeded());
if (!ra || !rb || !ra->succeeded() || !rb->succeeded()) {
return;
}
const auto lib_a = stage_a / "profiles" / "debug" / "out" / "librepro_lib.a";
const auto lib_b = stage_b / "profiles" / "debug" / "out" / "librepro_lib.a";
const auto exe_a = stage_a / "profiles" / "debug" / "out" / "bin" / "repro_app";
const auto exe_b = stage_b / "profiles" / "debug" / "out" / "bin" / "repro_app";
auto sha_lib_a = Util::sha256_file_hex(lib_a);
auto sha_lib_b = Util::sha256_file_hex(lib_b);
auto sha_exe_a = Util::sha256_file_hex(exe_a);
auto sha_exe_b = Util::sha256_file_hex(exe_b);
Void::Testing::expect(sha_lib_a.has_value() && sha_lib_b.has_value());
Void::Testing::expect(sha_exe_a.has_value() && sha_exe_b.has_value());
if (sha_lib_a && sha_lib_b) {
Void::Testing::expect_eq(*sha_lib_a, *sha_lib_b);
}
if (sha_exe_a && sha_exe_b) {
Void::Testing::expect_eq(*sha_exe_a, *sha_exe_b);
}
Platform::ProcessRequest run_a;
run_a.executable = exe_a;
auto out_a = Platform::run_supervised(run_a);
Void::Testing::expect(out_a.has_value() && out_a->succeeded());
if (out_a) {
Void::Testing::expect(out_a->stdout_data.starts_with("42|"));
}
}