feat(daemon): report per-target metadata on request
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 55s

This commit is contained in:
faumaray committed 2026-12-04 02:24:22 +03:00
1 parent cf06b427b7
commit 3a3376c331
8 files changed
+154 -3

No files matched your search

+1
View File
@@ -73,6 +73,7 @@ check_process(0 "Usage: vbs daemon compdb generations .*--profile" "" daemon com
check_process(0 "Usage: vbs daemon deps .*--profile" "" daemon deps --help)
check_process(0 "Usage: vbs daemon info " "" daemon info --help)
check_process(0 "Usage: vbs daemon clean " "" daemon clean --help)
check_process(0 "Usage: vbs daemon target info .*--name" "" daemon target info --help)
check_process(0 "Usage: vbs daemon ide wait .*--timeout-ms" "" daemon ide wait --help)
check_process(2 "" "missing subcommand for 'vbs daemon'" daemon)
+54
View File
@@ -1253,6 +1253,60 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(run_result.has_value());
}
VOID_TEST(Daemon, target_info_reports_target_details) {
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 info =
request_object(socket, R"({"op":"target_info","target":"app"})", std::chrono::seconds{120});
auto unknown = request_object(socket, R"({"op":"target_info","target":"nope"})",
std::chrono::seconds{120});
auto missing = request_object(socket, R"({"op":"target_info"})");
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(info.has_value());
Void::Testing::expect(bool_field(*info, "ok"));
Void::Testing::expect_eq(str_field(*info, "name"), std::string{"app"});
Void::Testing::expect_eq(str_field(*info, "kind"), std::string{"executable"});
Void::Testing::expect(!string_array_field(*info, "sources").empty());
Void::Testing::expect(!string_array_field(*info, "primary_outputs").empty());
Void::Testing::require(unknown.has_value());
Void::Testing::expect(!bool_field(*unknown, "ok", true));
Void::Testing::expect(str_field(*unknown, "error").find("unknown target") != std::string::npos);
Void::Testing::require(missing.has_value());
Void::Testing::expect(!bool_field(*missing, "ok", true));
}
VOID_TEST(Daemon, describe_empty_project_reports_zero_targets) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());