feat(daemon): export the profile compilation database over the Unix socket
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 16s

This commit is contained in:
faumaray committed 2026-12-03 20:30:19 +03:00
1 parent 8001d98bb7
commit 72f4237af2
9 files changed
+153 -21

No files matched your search

+50
View File
@@ -491,6 +491,56 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(raw->find("\"name\":\"app\"") != std::string::npos);
}
VOID_TEST(Daemon, compdb_export_publishes_compilation_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 raw = Void::Build::Daemon::request(socket, R"({"op":"compdb_export"})",
std::chrono::seconds{120});
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(bool_field(*object, "ok"));
Void::Testing::expect_eq(str_field(*object, "op"), std::string{"compdb"});
Void::Testing::expect(int_field(*object, "entries") >= 1);
const std::string compdb = str_field(*object, "compdb");
Void::Testing::expect(!compdb.empty());
Void::Testing::expect(std::filesystem::exists(compdb));
}
VOID_TEST(Daemon, describe_empty_project_reports_zero_targets) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());