feat(daemon): select the active editor profile over the socket
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 22s

This commit is contained in:
faumaray committed 2026-12-03 21:57:47 +03:00
1 parent 343e03c27c
commit 502f2b0c51
9 files changed
+120 -2

No files matched your search

+53
View File
@@ -737,6 +737,59 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(run_result.has_value());
}
VOID_TEST(Daemon, compdb_use_switches_active_editor_profile) {
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 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 selected = request_object(socket, R"({"op":"compdb_use","profile":"debug"})");
Void::Testing::require(selected.has_value());
Void::Testing::expect(bool_field(*selected, "ok"));
Void::Testing::expect_eq(str_field(*selected, "profile"), std::string{"debug"});
Void::Testing::expect(int_field(*selected, "ticket") >= 1);
const std::string compdb = str_field(*selected, "compdb");
Void::Testing::expect(!compdb.empty());
Void::Testing::expect(std::filesystem::exists(compdb));
auto missing = request_object(socket, R"({"op":"compdb_use","profile":"nope"})");
Void::Testing::require(missing.has_value());
Void::Testing::expect(!bool_field(*missing, "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());