feat(daemon): build and run declared test targets
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 18s

This commit is contained in:
faumaray committed 2026-12-03 22:47:12 +03:00
1 parent ae57ee7666
commit afea6f3fad
9 files changed
+177 -21

No files matched your search

+1 -1
View File
@@ -107,7 +107,7 @@ All CLI help text (`vbs --help`, `vbs <command> --help`, `vbs compdb --help`, `v
- `vbs binaries list|fetch --registry URL --name PKG --version X.Y.Z [--variant ID --output FILE] [--token-env VAR]`
- `vbs bridge --request FILE --output FILE` (backend for [cmake/bridge/VbsDeps.cmake](cmake/bridge/VbsDeps.cmake))
- `vbs gc [--build-dir DIR] [--max-bytes N]`
- `vbs daemon run|status|stop|gc|recover|describe|build|ide query|ide generate|ide poll|ide wait|ide status|compdb use|compdb export|graph [--format dot|json] [--project DIR] [--member NAME]` [--build-dir DIR] [--socket PATH]` (Unix-socket daemon holding a warm state store and project watcher; `run` serves in the foreground, the rest are client requests)
- `vbs daemon run|status|stop|gc|recover|describe|build|ide query|ide generate|ide poll|ide wait|ide status|compdb use|compdb export|graph [--format dot|json]|test [--target NAME] [--project DIR] [--member NAME]` [--build-dir DIR] [--socket PATH]` (Unix-socket daemon holding a warm state store and project watcher; `run` serves in the foreground, the rest are client requests)
- `vbs gen-tests --input FILE --output-dir DIR`
- `vbs-registry --data-dir DIR --web-root DIR [--bind ADDR] [--port PORT] ...`
+5 -1
View File
@@ -165,7 +165,11 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
- Added `POST /api/v1/packages/<name>/<version>/binaries/<variant>/yank` to `vbs-registry` (auth + CSRF, publish authority, `{"yanked":bool}` body defaulting to true) with `BinaryReleaseMeta::yanked` persisted and listed in detail JSON. `RegistryClient::fetch_binary_variants` now exposes `yanked` and never returns yanked variants for selection.
- The registry binary-variant test now checks unauthenticated yank rejection, CSRF-protected session yank, the yanked flag in the detail JSON, and that the yanked variant disappears from the client variant list.
- **Wave 37 (Daemon Graph Export)**:\n - Added the `graph` daemon request (`vbs daemon graph [--profile] [--format dot|json] [--member]`): evaluates the project (workspace-member aware) and returns the target dependency graph as Graphviz DOT or JSON inside a bounded JSON envelope (`profile`, `format`, `graph`).\n - Added `Daemon.graph_exports_target_dependencies_as_json_and_dot` (JSON and DOT payloads, invalid format rejected) and a CLI help contract; Daemon suite is now 16 cases.\n\n## Remaining future scope
- **Wave 37 (Daemon Graph Export)**:\n - Added the `graph` daemon request (`vbs daemon graph [--profile] [--format dot|json] [--member]`): evaluates the project (workspace-member aware) and returns the target dependency graph as Graphviz DOT or JSON inside a bounded JSON envelope (`profile`, `format`, `graph`).\n - Added `Daemon.graph_exports_target_dependencies_as_json_and_dot` (JSON and DOT payloads, invalid format rejected) and a CLI help contract; Daemon suite is now 16 cases.\n\n- **Wave 38 (Daemon Test Request)**:
- Added the `test` daemon request (`vbs daemon test [--profile] [--target] [--jobs]`): after the build succeeds it runs every declared `TargetKind::Test` binary (300 s timeout, bounded 4 KiB stdout/stderr tails) and reports `tests` entries with `tests_passed`/`tests_failed`; any failing test marks the response `ok=false`. Workspace-wide `test` aggregates per-member results.
- Added `Daemon.test_builds_and_runs_declared_tests` (one passing and one failing test target → `tests_passed=1`, `tests_failed=1`, `ok=false`) and a CLI help contract; Daemon suite is now 17 cases.
## Remaining future scope
- **Post-v1 Expansion Roadmap ([21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md) & [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md))**: Live `conan` CLI verification (Track B3), Track C (macOS/Windows ports + dual-profile cross-compilation), Track D3 signing (SBOM, Ed25519 primitives, trusted-key enforcement and distribution, binary-variant signing and distribution materialization, the #52 built-in-backend capability probe, and the VoidLibrary pin bump to `0002e74` done), Track E3 (daemon core, bounded `describe`, build-serving, dependency materialization, daemon-backed IDE metadata, compdb export, IDE config generation, editor watch poll and bounded long-poll done; dedicated external editor plugins remain), and Track E4 (`Void::Net`/`Void::Sqlite` alignment) remain planned scope.
+1
View File
@@ -44,4 +44,5 @@ Base HEAD: `fe0d1a6`
| Wave 35 (Daemon compdb use) | `compdb_use` daemon request + `vbs daemon compdb use --profile`: switches the active editor profile under the selection lock | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 15/15, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs |
| Wave 36 (Registry binary-variant yank) | `POST .../binaries/<variant>/yank`, persisted `yanked` flag in detail JSON, client filters yanked variants | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry suite 6/6, full CTest 8/8) | `registry/include/Void/Build/Registry/RegistryService.hpp`, `registry/service/RegistryService.cpp`, `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.cpp`, `tests/RegistryTests.cpp`, docs |
| Wave 37 (Daemon graph export) | `graph` daemon request + `vbs daemon graph --format dot|json --member`: target dependency graph in a JSON envelope | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 16/16, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs |
| Wave 38 (Daemon test request) | `test` daemon request + `vbs daemon test`: builds, runs declared test targets with bounded output, reports pass/fail counts | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 17/17, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs |
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions, E4, live `conan`) | Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
+14
View File
@@ -657,6 +657,20 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure
- Full CTest: **8 / 8 passed** in 214.59 s.
- `clang-format --dry-run --Werror` passes on the changed C++ files.
## Daemon Test Request (GCC 16.2, pin `0002e74`)
```sh
dev cpp-gcc -c cmake --build build/pinned --parallel 8
dev cpp-gcc -c build/pinned/bin/vbs_v1_tests --suite Daemon --no-color
dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure
```
- Build: exit 0. Daemon suite: **17 / 17 passed** in 34.83 s, including
`test_builds_and_runs_declared_tests`: a project with one passing and one failing test target
returns `op=test`, `ok=false`, `tests_passed=1`, and `tests_failed=1`.
- Full CTest: **8 / 8 passed** in 216.66 s.
- `clang-format --dry-run --Werror` passes on the changed C++ files.
## Limits and Unrun Checks
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
+1 -1
View File
@@ -73,7 +73,7 @@ flowchart LR
| --- | --- | --- |
| **E1 — Everyday CLI Ergonomics (Implemented in Wave 8)** | `vbs init` project scaffolding, `vbs clean`, `vbs doctor` environment diagnostics, `vbs graph --format dot|json`, and `vbs build --native-foreign`. | End-to-end CLI & integration tests passing in `vbs_cli_contract` and `vbs_v1_tests`. |
| **E2 — Multi-Package Workspaces (`workspace.cpp`)** *(verified in Docker GCC 16)* | Shared root `vbs.lock` and `build/.vbs` CAS, `workspace_dependency()` cross-member native linking, and affected-member selection (`vbs build/test --member <pkg>` / `--changed-since <ref>`). | 3-package workspace fixture (shared library + app + tests) builds/tests with one root lockfile; member selection and `--changed-since` verified in `FullV1Tests.workspace_members_shared_build_and_member_selection`. |
| **E3 — IDE Config/Query & Background Daemon** | `build.cpp`/`build.profiles.cpp`/`build-support/` SDK entries in `compile_commands.json` + `vbs ide generate` (`.clangd`, `.vscode/`, `.zed/`, `.idea/customTargets.xml`) & `vbs ide query` (**Implemented & Verified in Wave 10**); Unix-socket daemon core holding a warm `StateStore` + project `DirectoryWatcher` with `vbs daemon run\|status\|stop\|gc\|recover\|describe` (**Implemented & Verified in Wave 14; bounded `describe` added in the post-v1 daemon follow-up**). `describe` returns a bounded graph summary (`target_names` ≤ 128 entries × 200 bytes, `profile` ≤ 128 bytes, 10 s evaluation timeout); `vbs daemon build` executes the lowered graph in-process against the warm state store with bounded `profile`/`targets`/`jobs`, including daemon-side dependency resolution/materialization and provider import via `Package::resolve_and_materialize_dependencies`; `vbs daemon ide query` publishes/selects the profile compilation database and serves the IDE workspace/target metadata JSON over the socket, `vbs daemon compdb export` returns the published compilation-database path and entry count, `vbs daemon ide generate` writes the editor presets over the socket, `vbs daemon ide poll` exposes a bounded editor-extension watch protocol (changed paths, sequence, overflow state), `vbs daemon ide wait` adds a bounded long-poll variant, `vbs daemon ide status` reports the active editor selection and compdb state, `vbs daemon compdb use` switches the active editor profile under the selection lock, and `vbs daemon graph` exports the target dependency graph (DOT/JSON). Daemon workspace support describes members, builds all members in order (or a selected member) with the shared root lock, and serves member-scoped IDE query/generate/compdb requests via `--member`. Dedicated editor extensions remain planned. | `vbs ide` & `build.cpp` syntax-check verified in `FullV1Tests.cpp`; daemon lifecycle/status/gc/shutdown/describe verified in `DaemonTests.cpp` (6/6 under `dev cpp-gcc`); the live `vbs daemon describe` CLI round-trip is verified in `vbs_cli_contract`. |
| **E3 — IDE Config/Query & Background Daemon** | `build.cpp`/`build.profiles.cpp`/`build-support/` SDK entries in `compile_commands.json` + `vbs ide generate` (`.clangd`, `.vscode/`, `.zed/`, `.idea/customTargets.xml`) & `vbs ide query` (**Implemented & Verified in Wave 10**); Unix-socket daemon core holding a warm `StateStore` + project `DirectoryWatcher` with `vbs daemon run\|status\|stop\|gc\|recover\|describe` (**Implemented & Verified in Wave 14; bounded `describe` added in the post-v1 daemon follow-up**). `describe` returns a bounded graph summary (`target_names` ≤ 128 entries × 200 bytes, `profile` ≤ 128 bytes, 10 s evaluation timeout); `vbs daemon build` executes the lowered graph in-process against the warm state store with bounded `profile`/`targets`/`jobs`, including daemon-side dependency resolution/materialization and provider import via `Package::resolve_and_materialize_dependencies`; `vbs daemon ide query` publishes/selects the profile compilation database and serves the IDE workspace/target metadata JSON over the socket, `vbs daemon compdb export` returns the published compilation-database path and entry count, `vbs daemon ide generate` writes the editor presets over the socket, `vbs daemon ide poll` exposes a bounded editor-extension watch protocol (changed paths, sequence, overflow state), `vbs daemon ide wait` adds a bounded long-poll variant, `vbs daemon ide status` reports the active editor selection and compdb state, `vbs daemon compdb use` switches the active editor profile under the selection lock, `vbs daemon graph` exports the target dependency graph (DOT/JSON), and `vbs daemon test` builds and runs declared test targets. Daemon workspace support describes members, builds all members in order (or a selected member) with the shared root lock, and serves member-scoped IDE query/generate/compdb requests via `--member`. Dedicated editor extensions remain planned. | `vbs ide` & `build.cpp` syntax-check verified in `FullV1Tests.cpp`; daemon lifecycle/status/gc/shutdown/describe verified in `DaemonTests.cpp` (6/6 under `dev cpp-gcc`); the live `vbs daemon describe` CLI round-trip is verified in `vbs_cli_contract`. |
| **E4 — Transport & Storage Upstream Alignment** | Adopt `Void::Net` (`VL-004`/`VL-005`) and `Void::Sqlite` (`VL-011b`) when lightweight/bundled builds become available in minimal Nix toolchains, reducing VBS transport code further. | All `vbs_registry_tests` and `vbs_core_tests` pass on both minimal and full toolchains. |
---
+84 -13
View File
@@ -9,6 +9,7 @@
#include <Void/Build/Package/Lockfile.hpp>
#include <Void/Build/Package/Resolver.hpp>
#include <Void/Build/Package/Toml.hpp>
#include <Void/Build/Platform/ProcessSupervisor.hpp>
#include <Void/Build/Provenance/TrustedKeys.hpp>
#include <Void/Build/Provider/Provider.hpp>
#include <Void/Build/State/StateStore.hpp>
@@ -612,6 +613,23 @@ Void::Result::Result<std::size_t, std::string> materialize_project_dependencies(
// Bounded build-serving request: resolves dependencies, lowers the project graph, and executes it
// in-process against the daemon's warm StateStore.
struct TestOutcome {
std::string name;
bool passed{false};
int exit_code{-1};
std::string stdout_tail;
std::string stderr_tail;
};
constexpr std::size_t kMaxTestOutputBytes = 4096U;
std::string bounded_tail(const std::string &text) {
if (text.size() <= kMaxTestOutputBytes) {
return text;
}
return text.substr(text.size() - kMaxTestOutputBytes);
}
struct BuildOutcome {
std::string profile;
std::size_t targets{0};
@@ -623,13 +641,15 @@ struct BuildOutcome {
bool succeeded{false};
std::string diagnostic;
JsonValue::Array failed_actions;
std::vector<TestOutcome> tests;
std::size_t tests_passed{0};
std::size_t tests_failed{0};
};
Void::Result::Result<BuildOutcome, std::string>
execute_project_build(const DaemonOptions &options, State::StateStore &state,
std::string_view profile_name,
std::optional<CompilerFamily> compiler_override,
const std::vector<std::string> &selected_targets, std::size_t jobs) {
Void::Result::Result<BuildOutcome, std::string> execute_project_build(
const DaemonOptions &options, State::StateStore &state, std::string_view profile_name,
std::optional<CompilerFamily> compiler_override,
const std::vector<std::string> &selected_targets, std::size_t jobs, bool run_tests) {
auto evaluated = evaluate_project_graph(options, profile_name, compiler_override, "build");
if (!evaluated) {
return std::unexpected{evaluated.error()};
@@ -673,6 +693,43 @@ execute_project_build(const DaemonOptions &options, State::StateStore &state,
outcome.failed_actions.emplace_back(std::move(failure));
}
}
// Runs declared test targets after a successful build, mirroring `vbs test`.
if (run_tests && report->succeeded) {
for (const auto &target : graph->targets) {
if (target.kind != TargetKind::Test || target.primary_outputs.empty()) {
continue;
}
if (!selected_targets.empty() &&
!std::ranges::contains(selected_targets, target.name)) {
continue;
}
Void::Build::Platform::ProcessRequest test_request;
test_request.executable = target.primary_outputs.front();
test_request.working_directory = options.project_root;
test_request.timeout = std::chrono::seconds{300};
auto test_result = Void::Build::Platform::run_supervised(test_request);
TestOutcome test;
test.name = target.name;
if (!test_result) {
test.stderr_tail = test_result.error().message();
} else {
test.passed = test_result->succeeded();
test.exit_code = test_result->exit_code;
test.stdout_tail = bounded_tail(test_result->stdout_data);
test.stderr_tail = bounded_tail(test_result->stderr_data);
}
if (test.passed) {
++outcome.tests_passed;
} else {
++outcome.tests_failed;
}
outcome.tests.push_back(std::move(test));
}
if (outcome.tests_failed > 0) {
outcome.succeeded = false;
}
}
return outcome;
}
@@ -687,6 +744,19 @@ JsonValue::Object build_outcome_json(const BuildOutcome &outcome) {
object.emplace("failed", JsonValue{static_cast<std::int64_t>(outcome.failed)});
object.emplace("diagnostic", JsonValue{outcome.diagnostic});
object.emplace("failed_actions", JsonValue{outcome.failed_actions});
object.emplace("tests_passed", JsonValue{static_cast<std::int64_t>(outcome.tests_passed)});
object.emplace("tests_failed", JsonValue{static_cast<std::int64_t>(outcome.tests_failed)});
JsonValue::Array tests;
for (const auto &test : outcome.tests) {
JsonValue::Object entry;
entry.emplace("name", JsonValue{test.name});
entry.emplace("passed", JsonValue{test.passed});
entry.emplace("exit_code", JsonValue{static_cast<std::int64_t>(test.exit_code)});
entry.emplace("stdout", JsonValue{test.stdout_tail});
entry.emplace("stderr", JsonValue{test.stderr_tail});
tests.emplace_back(std::move(entry));
}
object.emplace("tests", JsonValue{std::move(tests)});
return object;
}
@@ -694,7 +764,7 @@ std::string build_project(const DaemonOptions &options, State::StateStore &state
std::string_view profile_name,
std::optional<CompilerFamily> compiler_override,
const std::vector<std::string> &selected_targets, std::size_t jobs,
std::string_view selected_member) {
std::string_view selected_member, bool run_tests) {
const bool workspace = Config::is_workspace_root(options.project_root);
// Workspace-wide build: every member in declared order, sharing the root lock and CAS.
@@ -710,8 +780,9 @@ std::string build_project(const DaemonOptions &options, State::StateStore &state
bool all_ok = true;
for (const auto &member : *members) {
const auto member_opts = member_options(options, member.path);
auto outcome = execute_project_build(member_opts, state, profile_name,
compiler_override, selected_targets, jobs);
auto outcome =
execute_project_build(member_opts, state, profile_name, compiler_override,
selected_targets, jobs, run_tests);
if (!outcome) {
return error_response(
std::format("build: member '{}': {}", member.name, outcome.error()));
@@ -727,7 +798,7 @@ std::string build_project(const DaemonOptions &options, State::StateStore &state
}
JsonValue::Object object;
object.emplace("ok", JsonValue{all_ok});
object.emplace("op", JsonValue{std::string{"build"}});
object.emplace("op", JsonValue{std::string{run_tests ? "test" : "build"}});
object.emplace("workspace", JsonValue{true});
object.emplace("members", JsonValue{std::move(member_array)});
object.emplace("executed", JsonValue{static_cast<std::int64_t>(executed)});
@@ -741,13 +812,13 @@ std::string build_project(const DaemonOptions &options, State::StateStore &state
return error_response(std::format("build: {}", effective_result.error()));
}
auto outcome = execute_project_build(*effective_result, state, profile_name, compiler_override,
selected_targets, jobs);
selected_targets, jobs, run_tests);
if (!outcome) {
return error_response(outcome.error());
}
JsonValue::Object object = build_outcome_json(*outcome);
object.emplace("ok", JsonValue{outcome->succeeded});
object.emplace("op", JsonValue{std::string{"build"}});
object.emplace("op", JsonValue{std::string{run_tests ? "test" : "build"}});
if (workspace) {
object.emplace("member", JsonValue{std::string{selected_member}});
}
@@ -1310,7 +1381,7 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
object.emplace("timed_out", JsonValue{timed_out});
return {serialize_response(JsonValue{std::move(object)}), false};
}
if (*name == "describe" || *name == "build" || *name == "ide_query" ||
if (*name == "describe" || *name == "build" || *name == "test" || *name == "ide_query" ||
*name == "ide_generate" || *name == "compdb_export" || *name == "graph") {
std::string profile_name{"debug"};
if (const auto entry = object->find("profile"); entry != object->end()) {
@@ -1417,7 +1488,7 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
jobs = static_cast<std::size_t>(*value);
}
return {build_project(options, state_store, profile_name, compiler_override,
selected_targets, jobs, member),
selected_targets, jobs, member, *name == "test"),
false};
}
if (*name == "shutdown") {
+14 -5
View File
@@ -1608,21 +1608,22 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
R"({{"op":"ide_query","profile":{}{}}})", Util::json_quote(opts.profile_arg),
opts.member_arg ? std::format(",\"member\":{}", Util::json_quote(*opts.member_arg))
: std::string{});
} else if (sub == "build") {
} else if (sub == "build" || sub == "test") {
std::size_t jobs = 0;
const auto [ptr, ec] = std::from_chars(opts.jobs_arg.data(),
opts.jobs_arg.data() + opts.jobs_arg.size(), jobs);
if (ec != std::errc{} || ptr != opts.jobs_arg.data() + opts.jobs_arg.size() || jobs > 256) {
std::cerr << "vbs daemon build: invalid --jobs value '" << opts.jobs_arg << "'\n";
std::cerr << "vbs daemon " << sub << ": invalid --jobs value '" << opts.jobs_arg
<< "'\n";
return 2;
}
if (opts.profile_arg.empty()) {
std::cerr << "vbs daemon build: --profile must not be empty\n";
std::cerr << "vbs daemon " << sub << ": --profile must not be empty\n";
return 2;
}
const std::string targets_json = Util::json_array(
opts.targets, [](const std::string &target) { return Util::json_quote(target); });
request_json = std::format(R"({{"op":"build","profile":{},"targets":{},"jobs":{}}})",
request_json = std::format(R"({{"op":"{}","profile":{},"targets":{},"jobs":{}}})", sub,
Util::json_quote(opts.profile_arg), targets_json, jobs);
} else {
std::cerr << "vbs daemon: unknown command '" << sub << "'\n";
@@ -1632,7 +1633,7 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
// Describe evaluates the whole project graph (descriptor compile, toolchain probe, lowering),
// which can exceed the 2 s default; the daemon bounds evaluation at 10 s.
const auto request_timeout =
sub == "build" ? std::chrono::milliseconds{std::chrono::hours{1}}
(sub == "build" || sub == "test") ? std::chrono::milliseconds{std::chrono::hours{1}}
: (sub == "watch_poll" || sub == "editor_status") ? std::chrono::milliseconds{5000}
: sub == "compdb_use" ? std::chrono::milliseconds{10000}
: sub == "watch_wait" ? std::chrono::milliseconds{10000}
@@ -2618,6 +2619,14 @@ int main(int argc, char **argv) {
.option_many("--target", "-t", "Target to build", daemon_opts.targets)
.option_default("--jobs", "-j", "Maximum parallel jobs (0 = hardware concurrency)",
daemon_opts.jobs_arg, "0");
auto &daemon_test_cmd =
daemon_cmd.subcommand("test", "Build and run declared test targets via the daemon");
configure_daemon_common(daemon_test_cmd);
daemon_test_cmd
.option_default("--profile", "-p", "Profile to build", daemon_opts.profile_arg, "debug")
.option_many("--target", "-t", "Target to build/test", daemon_opts.targets)
.option_default("--jobs", "-j", "Maximum parallel jobs (0 = hardware concurrency)",
daemon_opts.jobs_arg, "0");
auto &daemon_compdb_cmd =
daemon_cmd.subcommand("compdb", "Editor compilation database served by the daemon");
auto &daemon_compdb_use_cmd =
+1
View File
@@ -63,6 +63,7 @@ check_process(0 "Usage: vbs daemon ide generate .*--profile.*--editor.*--force"
check_process(0 "Usage: vbs daemon ide poll " "" daemon ide poll --help)
check_process(0 "Usage: vbs daemon ide status " "" daemon ide status --help)
check_process(0 "Usage: vbs daemon graph .*--format" "" daemon graph --help)
check_process(0 "Usage: vbs daemon test .*--profile.*--target.*--jobs" "" daemon test --help)
check_process(0 "Usage: vbs daemon ide wait .*--timeout-ms" "" daemon ide wait --help)
check_process(2 "" "missing subcommand for 'vbs daemon'" daemon)
+56
View File
@@ -853,6 +853,62 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(!bool_field(*invalid, "ok", true));
}
VOID_TEST(Daemon, test_builds_and_runs_declared_tests) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());
const auto options = make_options(temp->path());
{
std::ofstream descriptor{options.project_root / "build.cpp"};
descriptor << R"cpp(#include <Void/Build.hpp>
void build(Void::Build::Project &project) {
project.test("good_test")
.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"good.cpp"});
project.test("bad_test")
.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"bad.cpp"});
}
)cpp";
Void::Testing::require(descriptor.good());
}
{
std::ofstream source{options.project_root / "good.cpp"};
source << "int main() { return 0; }\n";
Void::Testing::require(source.good());
}
{
std::ofstream source{options.project_root / "bad.cpp"};
source << "int main() { return 3; }\n";
Void::Testing::require(source.good());
}
auto server = Void::Build::Daemon::DaemonServer::create(options);
Void::Testing::require(server.has_value());
const auto socket = server->socket_path();
Void::Result::Result<void, Void::Result::Error> run_result;
std::jthread worker{[&] { run_result = server->run(); }};
Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5}));
auto raw = Void::Build::Daemon::request(socket, R"({"op":"test"})", std::chrono::seconds{300});
auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})");
Void::Testing::expect(shutdown.has_value());
worker.join();
Void::Testing::expect(run_result.has_value());
Void::Testing::require(raw.has_value());
const auto parsed = parse_json(*raw);
Void::Testing::require(parsed.has_value());
const auto *object = as_object(*parsed);
Void::Testing::require(object != nullptr);
Void::Testing::expect_eq(str_field(*object, "op"), std::string{"test"});
Void::Testing::expect(!bool_field(*object, "ok", true));
Void::Testing::expect_eq(int_field(*object, "tests_passed"), std::int64_t{1});
Void::Testing::expect_eq(int_field(*object, "tests_failed"), std::int64_t{1});
}
VOID_TEST(Daemon, describe_empty_project_reports_zero_targets) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());