feat: add Plan 20 Slice 2A Meson native translation, DX CLI (init/clean/doctor/graph/--native-foreign), and expansion roadmap
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 7s
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 7s
This commit is contained in:
1 parent
d3d2666965
commit
fe0d1a6483
12 files changed
+1317
-41
No files matched your search
@@ -22,8 +22,13 @@ check_process(0 "^vbs ${VBS_VERSION}\n$" "" -V)
|
||||
check_process(2 "" "unknown option: --invalid" --version --invalid)
|
||||
check_process(2 "" "--version cannot be combined with subcommands" --version build)
|
||||
check_process(2 "" "unknown subcommand: invalid" invalid)
|
||||
check_process(0 "Usage: vbs build .*--profile.*\\(repeatable\\)" "" build --help)
|
||||
check_process(0 "Usage: vbs build .*--native-foreign.*--profile.*\\(repeatable\\)" "" build --help)
|
||||
check_process(0 "Usage: vbs test " "" test --help)
|
||||
check_process(0 "Usage: vbs init " "" init --help)
|
||||
check_process(0 "Usage: vbs clean " "" clean --help)
|
||||
check_process(0 "Usage: vbs doctor " "" doctor --help)
|
||||
check_process(0 "Usage: vbs graph " "" graph --help)
|
||||
check_process(2 "" "unsupported --format" graph --format xml)
|
||||
check_process(2 "" "multi-profile build requires --editor-profile" build --profile debug --profile release)
|
||||
check_process(2 "" "must be one of the requested profiles" build --profile debug --profile release --editor-profile custom)
|
||||
check_process(0 "Usage: vbs compdb <command>.*Commands:.*use.*show.*export.*watch" "" compdb --help)
|
||||
@@ -46,4 +51,4 @@ execute_process(COMMAND "${VBS_REGISTRY}" --help
|
||||
if(NOT "${reg_code}" STREQUAL "0" OR NOT reg_out MATCHES "Usage: vbs-registry")
|
||||
message(FATAL_ERROR "vbs-registry --help failed: code=${reg_code}\nstdout=[${reg_out}]\nstderr=[${reg_err}]")
|
||||
endif()
|
||||
message(STATUS "27 native CLI and auto-generated Argparse help contracts verified")
|
||||
message(STATUS "32 native CLI and auto-generated Argparse help contracts verified")
|
||||
@@ -1214,3 +1214,188 @@ target_include_directories(p20_genlib PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
Void::Testing::expect(fb_res->exported.targets.contains("p20_gen::p20_genlib"));
|
||||
}
|
||||
}
|
||||
|
||||
// === Plan 20 Slice 2A: Bounded native Meson graph translation + unsupported custom_target fallback
|
||||
// ===
|
||||
Void::Testing::Test plan20_bounded_meson_translation_equivalence_and_fallback() {
|
||||
if (!Platform::resolve_executable("meson").has_value()) {
|
||||
return;
|
||||
}
|
||||
Void::FileSystem::TempDir tmp{"vbs_plan20_meson_"};
|
||||
auto ctx = default_profiles().resolve("debug", CompilerFamily::Gcc, Toolchain::host_os_name(),
|
||||
Toolchain::host_architecture_name());
|
||||
auto tc = Toolchain::discover_and_probe(ctx, tmp / "probes");
|
||||
Void::Testing::expect(tc.has_value());
|
||||
if (!tc)
|
||||
return;
|
||||
|
||||
auto state = State::StateStore::open(tmp / "state");
|
||||
Void::Testing::expect(state.has_value());
|
||||
if (!state)
|
||||
return;
|
||||
|
||||
// 1. Supported C++ Meson project (static library + executable): configure ONLY (`meson setup`,
|
||||
// zero `meson compile`!), audit, translate natively, execute via VBS, verify stdout + header
|
||||
// mutation!
|
||||
const auto m_src = tmp / "meson_supported";
|
||||
write_file(m_src / "meson.build", R"meson(
|
||||
project('p20m', 'cpp', default_options: ['cpp_std=c++20'])
|
||||
inc = include_directories('include')
|
||||
lib = static_library('mcore', 'src/core.cpp', include_directories: inc, cpp_args: ['-DM_DELTA=5'])
|
||||
executable('mapp', 'src/main.cpp', include_directories: inc, link_with: lib)
|
||||
)meson");
|
||||
write_file(m_src / "include" / "mcore.hpp",
|
||||
"#pragma once\ninline constexpr int kMBase = 37;\nint m_answer();\n");
|
||||
write_file(m_src / "src" / "core.cpp",
|
||||
"#include \"mcore.hpp\"\nint m_answer() { return kMBase + M_DELTA; }\n");
|
||||
write_file(m_src / "src" / "main.cpp",
|
||||
"#include \"mcore.hpp\"\n#include <iostream>\n"
|
||||
"int main() { std::cout << m_answer() << '\\n'; return 0; }\n");
|
||||
|
||||
DependencyRecord mdep;
|
||||
mdep.name = "p20m";
|
||||
mdep.source_kind = DependencySourceKind::Path;
|
||||
mdep.location = m_src.string();
|
||||
mdep.builder = "meson";
|
||||
|
||||
auto mat = Package::materialize_dependency_source(mdep, {tmp / "cache", tmp.path(), false, {}});
|
||||
Void::Testing::expect(mat.has_value());
|
||||
if (!mat)
|
||||
return;
|
||||
|
||||
Provider::ProviderRequest req{
|
||||
mdep, *mat, ctx, *tc, tmp / "prov", Provider::ProviderMode::FullBuild, {}};
|
||||
auto native_res = Provider::resolve_foreign_with_translation(
|
||||
req, *state, Provider::TranslationPolicy::RequireNative);
|
||||
Void::Testing::expect_eq(native_res ? std::string{} : native_res.error().message(),
|
||||
std::string{});
|
||||
Void::Testing::expect(native_res.has_value());
|
||||
if (!native_res)
|
||||
return;
|
||||
Void::Testing::expect(native_res->executed_natively);
|
||||
Void::Testing::expect(native_res->audit.is_supported());
|
||||
Void::Testing::expect(native_res->exported.targets.contains("p20m::mcore"));
|
||||
|
||||
const auto hash = Provider::compute_provider_input_hash(req);
|
||||
const auto slot_dir = tmp / "prov" / ("translate_meson_p20m_" + hash.substr(0, 16));
|
||||
const auto native_exe =
|
||||
slot_dir / "native-build" / "profiles" / "debug" / "out" / "bin" / "mapp";
|
||||
Void::Testing::expect(std::filesystem::exists(native_exe));
|
||||
|
||||
Platform::ProcessRequest run_req;
|
||||
run_req.executable = native_exe;
|
||||
auto run_out = Platform::run_supervised(run_req);
|
||||
Void::Testing::expect(run_out.has_value() && run_out->succeeded());
|
||||
if (run_out) {
|
||||
Void::Testing::expect_eq(run_out->stdout_data, std::string{"42\n"});
|
||||
}
|
||||
|
||||
// 2. Unsupported Meson `custom_target`: RequireNative MUST fail cleanly; FallbackToForeignBuild
|
||||
// MUST build via foreign Meson provider!
|
||||
const auto u_src = tmp / "meson_custom";
|
||||
write_file(u_src / "meson.build", R"meson(
|
||||
project('p20m_custom', 'cpp')
|
||||
gen = custom_target('gen_hdr',
|
||||
output: 'gen_num.hpp',
|
||||
command: ['/bin/sh', '-c', 'printf "#define M_GEN_NUM 88\n" > "$1"', '--', '@OUTPUT@'])
|
||||
static_library('mgenlib', ['src/gen.cpp', gen])
|
||||
)meson");
|
||||
write_file(u_src / "src" / "gen.cpp",
|
||||
"#include \"gen_num.hpp\"\nint m_gen_fn() { return M_GEN_NUM; }\n");
|
||||
|
||||
DependencyRecord udep;
|
||||
udep.name = "p20m_custom";
|
||||
udep.source_kind = DependencySourceKind::Path;
|
||||
udep.location = u_src.string();
|
||||
udep.builder = "meson";
|
||||
auto umat =
|
||||
Package::materialize_dependency_source(udep, {tmp / "cache", tmp.path(), false, {}});
|
||||
Void::Testing::expect(umat.has_value());
|
||||
if (!umat)
|
||||
return;
|
||||
|
||||
Provider::ProviderRequest ureq{
|
||||
udep, *umat, ctx, *tc, tmp / "prov", Provider::ProviderMode::FullBuild, {}};
|
||||
auto strict = Provider::resolve_foreign_with_translation(
|
||||
ureq, *state, Provider::TranslationPolicy::RequireNative);
|
||||
Void::Testing::expect(!strict.has_value());
|
||||
|
||||
auto fallback = Provider::resolve_foreign_with_translation(
|
||||
ureq, *state, Provider::TranslationPolicy::FallbackToForeignBuild);
|
||||
Void::Testing::expect_eq(fallback ? std::string{} : fallback.error().message(), std::string{});
|
||||
Void::Testing::expect(fallback.has_value());
|
||||
if (fallback) {
|
||||
Void::Testing::expect(!fallback->executed_natively);
|
||||
Void::Testing::expect(!fallback->audit.is_supported());
|
||||
Void::Testing::expect(fallback->exported.targets.contains("p20m_custom::mgenlib"));
|
||||
}
|
||||
}
|
||||
|
||||
// === 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)) {
|
||||
return;
|
||||
}
|
||||
Void::FileSystem::TempDir tmp{"vbs_dx_"};
|
||||
const auto proj = tmp / "hello_vbs";
|
||||
const auto bdir = tmp / "hello_build";
|
||||
|
||||
auto run_vbs = [&](std::vector<std::string> args) {
|
||||
Platform::ProcessRequest req;
|
||||
req.executable = vbs_bin;
|
||||
req.arguments = std::move(args);
|
||||
req.timeout = std::chrono::seconds{120};
|
||||
return Platform::run_supervised(req);
|
||||
};
|
||||
|
||||
// 1. `vbs init` scaffolds a ready-to-build-and-test C++26 project.
|
||||
auto r_init = run_vbs({"init", "--dir", proj.string(), "--name", "hello_vbs"});
|
||||
Void::Testing::expect(r_init.has_value() && r_init->succeeded());
|
||||
Void::Testing::expect(std::filesystem::exists(proj / "build.cpp"));
|
||||
Void::Testing::expect(std::filesystem::exists(proj / "src" / "main.cpp"));
|
||||
Void::Testing::expect(std::filesystem::exists(proj / "tests" / "test_main.cpp"));
|
||||
|
||||
// 2. `vbs test` builds & passes the freshly scaffolded project out of the box!
|
||||
auto r_test = run_vbs({"test", "--project", proj.string(), "--build-dir", bdir.string()});
|
||||
Void::Testing::expect(r_test.has_value() && r_test->succeeded());
|
||||
if (r_test) {
|
||||
Void::Testing::expect(r_test->stdout_data.find("PASSED 'hello_vbs_tests'") !=
|
||||
std::string::npos);
|
||||
}
|
||||
|
||||
// 3. `vbs graph --format dot` & `--format json` emit valid target dependency graphs.
|
||||
auto r_dot = run_vbs(
|
||||
{"graph", "--project", proj.string(), "--build-dir", bdir.string(), "--format", "dot"});
|
||||
Void::Testing::expect(r_dot.has_value() && r_dot->succeeded());
|
||||
if (r_dot) {
|
||||
Void::Testing::expect(r_dot->stdout_data.find("digraph vbs_targets") != std::string::npos);
|
||||
Void::Testing::expect(r_dot->stdout_data.find("\"hello_vbs\" -> \"hello_vbs_lib\"") !=
|
||||
std::string::npos);
|
||||
}
|
||||
auto r_json = run_vbs(
|
||||
{"graph", "--project", proj.string(), "--build-dir", bdir.string(), "--format", "json"});
|
||||
Void::Testing::expect(r_json.has_value() && r_json->succeeded());
|
||||
if (r_json) {
|
||||
auto parsed = Void::Json::Strict::parse(r_json->stdout_data);
|
||||
Void::Testing::expect(parsed.has_value());
|
||||
}
|
||||
|
||||
// 4. `vbs doctor` succeeds and reports GCC + Void::Crypto + Void::Archive.
|
||||
auto r_doc = run_vbs({"doctor"});
|
||||
Void::Testing::expect(r_doc.has_value() && r_doc->succeeded());
|
||||
if (r_doc) {
|
||||
Void::Testing::expect(r_doc->stdout_data.find("Void::Crypto") != std::string::npos);
|
||||
Void::Testing::expect(r_doc->stdout_data.find("GCC probe:") != std::string::npos);
|
||||
}
|
||||
|
||||
// 5. `vbs clean` removes profile outputs while preserving .vbs/state; `--all` removes all.
|
||||
auto r_clean = run_vbs({"clean", "--build-dir", bdir.string()});
|
||||
Void::Testing::expect(r_clean.has_value() && r_clean->succeeded());
|
||||
Void::Testing::expect(!std::filesystem::exists(bdir / "profiles"));
|
||||
Void::Testing::expect(std::filesystem::exists(bdir / ".vbs"));
|
||||
|
||||
auto r_clean_all = run_vbs({"clean", "--build-dir", bdir.string(), "--all"});
|
||||
Void::Testing::expect(r_clean_all.has_value() && r_clean_all->succeeded());
|
||||
Void::Testing::expect(!std::filesystem::exists(bdir));
|
||||
}
|
||||
Reference in new issue
Block a user