feat(daemon): serve bounded compile command entries to editor extensions
This commit is contained in:
1 parent
afea6f3fad
commit
40fef50a6f
9 files changed
+237
-2
No files matched your search
@@ -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]|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 daemon run|status|stop|gc|recover|describe|build|ide query|ide generate|ide poll|ide wait|ide status|compdb use|compdb export|compdb entries [--file PATH] [--limit N]|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] ...`
|
||||
|
||||
|
||||
@@ -169,6 +169,10 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
|
||||
- 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.
|
||||
|
||||
- **Wave 39 (Compdb Entries Query)**:
|
||||
- Added the `compdb_entries` daemon request (`vbs daemon compdb entries [--file SUFFIX] [--limit N]`): reads the active published compilation database (selection state or root alias), returns bounded projected entries (`file`, `directory`, `output`, `command`, bounded `arguments`), reports `total`/`returned`, and errors explicitly when nothing is published.
|
||||
- Added `Daemon.compdb_entries_queries_published_database` (unpublished → error, then all entries, a `main.cpp` filter with `limit:1`, and an invalid limit) and a CLI help contract; Daemon suite is now 18 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.
|
||||
|
||||
@@ -45,4 +45,5 @@ Base HEAD: `fe0d1a6`
|
||||
| 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 |
|
||||
| Wave 39 (Compdb entries query) | `compdb_entries` daemon request + `vbs daemon compdb entries --file --limit`: bounded projected entries from the active compdb | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 18/18, 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) |
|
||||
@@ -671,6 +671,22 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure
|
||||
- Full CTest: **8 / 8 passed** in 216.66 s.
|
||||
- `clang-format --dry-run --Werror` passes on the changed C++ files.
|
||||
|
||||
## Compdb Entries Query (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: **18 / 18 passed** in 36.85 s, including
|
||||
`compdb_entries_queries_published_database`: before export the request fails explicitly; after
|
||||
`compdb_export`, all entries are returned, `{"file":"main.cpp","limit":1}` returns at most one
|
||||
entry whose file ends with `main.cpp` and includes bounded `arguments`, and `limit:501` is
|
||||
rejected.
|
||||
- Full CTest: **8 / 8 passed** in 218.84 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).
|
||||
|
||||
@@ -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, `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`. |
|
||||
| **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), `vbs daemon test` builds and runs declared test targets, and `vbs daemon compdb entries` serves bounded per-file compile arguments to editor extensions. 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. |
|
||||
|
||||
---
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <Void/Configuration/Env.hpp>
|
||||
#include <Void/Data/StrictJson.hpp>
|
||||
#include <Void/Functional/Error.hpp>
|
||||
#include <Void/System/Path.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cerrno>
|
||||
@@ -60,6 +61,9 @@ constexpr std::size_t kMaxDescribeProfileBytes = 128U;
|
||||
constexpr std::size_t kMaxDescribeTargetNames = 128U;
|
||||
constexpr std::size_t kMaxDescribeTargetNameBytes = 200U;
|
||||
constexpr std::size_t kMaxBuildTargets = 64U;
|
||||
constexpr std::size_t kMaxCompdbArguments = 256U;
|
||||
constexpr std::size_t kMaxCompdbArgumentBytes = 1024U;
|
||||
constexpr std::size_t kMaxCompdbEntries = 500U;
|
||||
constexpr std::size_t kMaxPendingChanges = 4096U;
|
||||
constexpr std::int64_t kMaxWatchWaitMs = 5000;
|
||||
constexpr std::int64_t kDefaultWatchWaitMs = 2000;
|
||||
@@ -946,6 +950,109 @@ std::string graph_project(const DaemonOptions &options, std::string_view profile
|
||||
",\"graph\":" + Util::json_quote(rendered) + '}';
|
||||
}
|
||||
|
||||
// Returns bounded compile_commands entries from the active compilation database, optionally
|
||||
// filtered by a path suffix. Editor extensions use this instead of parsing the file themselves.
|
||||
std::string compdb_entries_project(const DaemonOptions &options, std::string_view file_filter,
|
||||
std::size_t limit) {
|
||||
auto selection = Editor::read_selection_state(options.project_root);
|
||||
if (!selection) {
|
||||
return error_response(std::format("compdb_entries: {}", selection.error().format()));
|
||||
}
|
||||
std::filesystem::path compdb_path;
|
||||
if (selection->has_value()) {
|
||||
compdb_path = (*selection)->selected_compdb_path;
|
||||
} else {
|
||||
std::error_code ec;
|
||||
const auto root_alias = options.build_root / "compile_commands.json";
|
||||
if (std::filesystem::exists(root_alias, ec)) {
|
||||
compdb_path = root_alias;
|
||||
}
|
||||
}
|
||||
if (compdb_path.empty()) {
|
||||
return error_response(
|
||||
"compdb_entries: no compilation database is published; run compdb export first");
|
||||
}
|
||||
|
||||
auto text = Void::FileSystem::read_file(compdb_path);
|
||||
if (!text) {
|
||||
return error_response(std::format("compdb_entries: {}", text.error().format()));
|
||||
}
|
||||
auto parsed = Void::Json::Strict::parse(*text);
|
||||
if (!parsed) {
|
||||
return error_response("compdb_entries: compilation database is not valid JSON");
|
||||
}
|
||||
const auto *entries = std::get_if<JsonValue::Array>(&parsed->value);
|
||||
if (entries == nullptr) {
|
||||
return error_response("compdb_entries: compilation database must be a JSON array");
|
||||
}
|
||||
|
||||
JsonValue::Array matched;
|
||||
std::size_t total = 0;
|
||||
for (const auto &entry : *entries) {
|
||||
const auto *object = std::get_if<JsonValue::Object>(&entry.value);
|
||||
if (object == nullptr) {
|
||||
continue;
|
||||
}
|
||||
const auto file_it = object->find("file");
|
||||
if (file_it == object->end()) {
|
||||
continue;
|
||||
}
|
||||
const auto *file = std::get_if<std::string>(&file_it->second.value);
|
||||
if (file == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (!file_filter.empty() &&
|
||||
!std::string_view{*file}.ends_with(std::string_view{file_filter})) {
|
||||
continue;
|
||||
}
|
||||
++total;
|
||||
if (matched.size() >= limit) {
|
||||
continue;
|
||||
}
|
||||
JsonValue::Object projected;
|
||||
projected.emplace("file", JsonValue{*file});
|
||||
const auto copy_string = [&](std::string_view field_name) {
|
||||
if (const auto it = object->find(field_name); it != object->end()) {
|
||||
if (const auto *value = std::get_if<std::string>(&it->second.value)) {
|
||||
projected.emplace(std::string{field_name}, JsonValue{*value});
|
||||
}
|
||||
}
|
||||
};
|
||||
copy_string("directory");
|
||||
copy_string("output");
|
||||
copy_string("command");
|
||||
if (const auto it = object->find("arguments"); it != object->end()) {
|
||||
if (const auto *arguments = std::get_if<JsonValue::Array>(&it->second.value)) {
|
||||
JsonValue::Array bounded;
|
||||
for (const auto &argument : *arguments) {
|
||||
const auto *value = std::get_if<std::string>(&argument.value);
|
||||
if (value == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (bounded.size() >= kMaxCompdbArguments) {
|
||||
projected.emplace("arguments_truncated", JsonValue{true});
|
||||
break;
|
||||
}
|
||||
bounded.emplace_back(value->size() > kMaxCompdbArgumentBytes
|
||||
? value->substr(0, kMaxCompdbArgumentBytes)
|
||||
: *value);
|
||||
}
|
||||
projected.emplace("arguments", JsonValue{std::move(bounded)});
|
||||
}
|
||||
}
|
||||
matched.emplace_back(std::move(projected));
|
||||
}
|
||||
|
||||
JsonValue::Object object;
|
||||
object.emplace("ok", JsonValue{true});
|
||||
object.emplace("op", JsonValue{std::string{"compdb_entries"}});
|
||||
object.emplace("compdb", JsonValue{compdb_path.string()});
|
||||
object.emplace("total", JsonValue{static_cast<std::int64_t>(total)});
|
||||
object.emplace("returned", JsonValue{static_cast<std::int64_t>(matched.size())});
|
||||
object.emplace("entries", JsonValue{std::move(matched)});
|
||||
return serialize_response(JsonValue{std::move(object)});
|
||||
}
|
||||
|
||||
// Switches the active editor profile to an already-published compilation database.
|
||||
std::string compdb_use_project(const DaemonOptions &options, std::string_view profile_name) {
|
||||
auto state =
|
||||
@@ -1332,6 +1439,28 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
|
||||
if (*name == "editor_status") {
|
||||
return {editor_status_project(options), false};
|
||||
}
|
||||
if (*name == "compdb_entries") {
|
||||
std::string file_filter;
|
||||
if (const auto entry = object->find("file"); entry != object->end()) {
|
||||
const auto *value = std::get_if<std::string>(&entry->second.value);
|
||||
if (value == nullptr || value->size() > 4096) {
|
||||
return {error_response("\"file\" must be a bounded string"), false};
|
||||
}
|
||||
file_filter = *value;
|
||||
}
|
||||
std::size_t limit = 50;
|
||||
if (const auto entry = object->find("limit"); entry != object->end()) {
|
||||
const auto *value = std::get_if<std::int64_t>(&entry->second.value);
|
||||
if (value == nullptr || *value < 0 ||
|
||||
*value > static_cast<std::int64_t>(kMaxCompdbEntries)) {
|
||||
return {error_response(std::format("\"limit\" must be an integer in [0, {}]",
|
||||
kMaxCompdbEntries)),
|
||||
false};
|
||||
}
|
||||
limit = static_cast<std::size_t>(*value);
|
||||
}
|
||||
return {compdb_entries_project(options, file_filter, limit), false};
|
||||
}
|
||||
if (*name == "compdb_use") {
|
||||
const auto entry = object->find("profile");
|
||||
if (entry == object->end()) {
|
||||
|
||||
@@ -1471,6 +1471,8 @@ struct DaemonCmdOptions {
|
||||
std::string editor_arg{"all"};
|
||||
std::optional<std::string> member_arg;
|
||||
std::string graph_format_arg{"dot"};
|
||||
std::optional<std::string> file_filter_arg;
|
||||
std::string limit_arg{"50"};
|
||||
std::string timeout_ms_arg{"2000"};
|
||||
bool force{false};
|
||||
std::string max_bytes_arg{"0"};
|
||||
@@ -1558,6 +1560,12 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
|
||||
Util::json_quote(opts.graph_format_arg));
|
||||
} else if (sub == "editor_status") {
|
||||
request_json = R"({"op":"editor_status"})";
|
||||
} else if (sub == "compdb_entries") {
|
||||
request_json =
|
||||
std::format(R"({{"op":"compdb_entries","limit":{}{}}})", opts.limit_arg,
|
||||
opts.file_filter_arg
|
||||
? std::format(",\"file\":{}", Util::json_quote(*opts.file_filter_arg))
|
||||
: std::string{});
|
||||
} else if (sub == "watch_poll") {
|
||||
request_json = R"({"op":"watch_poll"})";
|
||||
} else if (sub == "watch_wait") {
|
||||
@@ -2629,6 +2637,14 @@ int main(int argc, char **argv) {
|
||||
daemon_opts.jobs_arg, "0");
|
||||
auto &daemon_compdb_cmd =
|
||||
daemon_cmd.subcommand("compdb", "Editor compilation database served by the daemon");
|
||||
auto &daemon_compdb_entries_cmd = daemon_compdb_cmd.subcommand(
|
||||
"entries", "Query bounded compile_commands entries for editor extensions");
|
||||
configure_daemon_common(daemon_compdb_entries_cmd);
|
||||
daemon_compdb_entries_cmd
|
||||
.option("--file", "", "Only entries whose source path ends with this value",
|
||||
daemon_opts.file_filter_arg)
|
||||
.option_default("--limit", "", "Maximum entries returned (0-500)", daemon_opts.limit_arg,
|
||||
"50");
|
||||
auto &daemon_compdb_use_cmd =
|
||||
daemon_compdb_cmd.subcommand("use", "Select an already-published editor profile");
|
||||
configure_daemon_common(daemon_compdb_use_cmd);
|
||||
|
||||
@@ -59,6 +59,7 @@ check_process(0 "Usage: vbs daemon build .*--profile.*--target.*--jobs" "" daemo
|
||||
check_process(0 "Usage: vbs daemon ide query .*--profile" "" daemon ide query --help)
|
||||
check_process(0 "Usage: vbs daemon compdb export .*--profile" "" daemon compdb export --help)
|
||||
check_process(0 "Usage: vbs daemon compdb use .*--profile" "" daemon compdb use --help)
|
||||
check_process(0 "Usage: vbs daemon compdb entries .*--file.*--limit" "" daemon compdb entries --help)
|
||||
check_process(0 "Usage: vbs daemon ide generate .*--profile.*--editor.*--force" "" daemon ide generate --help)
|
||||
check_process(0 "Usage: vbs daemon ide poll " "" daemon ide poll --help)
|
||||
check_process(0 "Usage: vbs daemon ide status " "" daemon ide status --help)
|
||||
|
||||
@@ -909,6 +909,74 @@ void build(Void::Build::Project &project) {
|
||||
Void::Testing::expect_eq(int_field(*object, "tests_failed"), std::int64_t{1});
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, compdb_entries_queries_published_database) {
|
||||
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) {
|
||||
auto app = project.executable("app");
|
||||
app.sources({"main.cpp"});
|
||||
}
|
||||
)cpp";
|
||||
Void::Testing::require(descriptor.good());
|
||||
}
|
||||
{
|
||||
std::ofstream source{options.project_root / "main.cpp"};
|
||||
source << "int main() { return 0; }\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 unpublished = request_object(socket, R"({"op":"compdb_entries"})");
|
||||
Void::Testing::require(unpublished.has_value());
|
||||
Void::Testing::expect(!bool_field(*unpublished, "ok", true));
|
||||
|
||||
auto exported = request_object(socket, R"({"op":"compdb_export"})", std::chrono::seconds{120});
|
||||
Void::Testing::require(exported.has_value());
|
||||
Void::Testing::expect(bool_field(*exported, "ok"));
|
||||
|
||||
auto all = request_object(socket, R"({"op":"compdb_entries"})");
|
||||
Void::Testing::require(all.has_value());
|
||||
Void::Testing::expect(bool_field(*all, "ok"));
|
||||
Void::Testing::expect(int_field(*all, "total") >= 1);
|
||||
Void::Testing::expect(int_field(*all, "returned") >= 1);
|
||||
|
||||
auto filtered =
|
||||
request_object(socket, R"({"op":"compdb_entries","file":"main.cpp","limit":1})");
|
||||
Void::Testing::require(filtered.has_value());
|
||||
Void::Testing::expect(bool_field(*filtered, "ok"));
|
||||
Void::Testing::expect(int_field(*filtered, "returned") <= 1);
|
||||
const auto *entries = field(*filtered, "entries");
|
||||
Void::Testing::require(entries != nullptr);
|
||||
const auto *entry_array = std::get_if<JsonValue::Array>(&entries->value);
|
||||
Void::Testing::require(entry_array != nullptr && !entry_array->empty());
|
||||
const auto *first = std::get_if<JsonObject>(&entry_array->front().value);
|
||||
Void::Testing::require(first != nullptr);
|
||||
Void::Testing::expect(str_field(*first, "file").find("main.cpp") != std::string::npos);
|
||||
Void::Testing::expect(field(*first, "arguments") != nullptr);
|
||||
|
||||
auto invalid_limit = request_object(socket, R"({"op":"compdb_entries","limit":501})");
|
||||
Void::Testing::require(invalid_limit.has_value());
|
||||
Void::Testing::expect(!bool_field(*invalid_limit, "ok", true));
|
||||
|
||||
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_TEST(Daemon, describe_empty_project_reports_zero_targets) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
|
||||
Reference in new issue
Block a user