feat(daemon): serve bounded in-process build requests over the Unix socket
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 10s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 16s

This commit is contained in:
faumaray committed 2026-12-03 18:07:10 +03:00
1 parent 85f2ae274f
commit 55272d3e6b
8 files changed
+238 -28

No files matched your search

+58
View File
@@ -310,6 +310,64 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(!std::filesystem::exists(socket));
}
VOID_TEST(Daemon, build_executes_project_graph_and_reuses_cache) {
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 build = request_object(socket, R"({"op":"build"})");
Void::Testing::require(build.has_value());
Void::Testing::expect(bool_field(*build, "ok"));
Void::Testing::expect_eq(str_field(*build, "op"), std::string{"build"});
Void::Testing::expect(int_field(*build, "executed") >= 1);
Void::Testing::expect(int_field(*build, "failed") == 0);
Void::Testing::expect(
std::filesystem::exists(options.build_root / "profiles" / "debug" / "out" / "bin" / "app"));
auto cached = request_object(socket, R"({"op":"build"})");
Void::Testing::require(cached.has_value());
Void::Testing::expect(bool_field(*cached, "ok"));
Void::Testing::expect(int_field(*cached, "executed") == 0);
Void::Testing::expect(int_field(*cached, "cached") >= 1);
auto bad_targets = request_object(socket, R"({"op":"build","targets":"app"})");
Void::Testing::require(bad_targets.has_value());
Void::Testing::expect(!bool_field(*bad_targets, "ok", true));
Void::Testing::expect(str_field(*bad_targets, "error").find("must be an array") !=
std::string::npos);
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::expect(!std::filesystem::exists(socket));
}
VOID_TEST(Daemon, describe_empty_project_reports_zero_targets) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());