feat(daemon): add editor-extension watch poll protocol
This commit is contained in:
1 parent
e15e2cb2b4
commit
c7a6bad3c0
9 files changed
+122
-14
No files matched your search
@@ -596,6 +596,46 @@ void build(Void::Build::Project &project) {
|
||||
Void::Testing::expect(std::filesystem::exists(options.project_root / ".clangd"));
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, watch_poll_reports_changed_paths) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
const auto options = make_options(temp->path());
|
||||
|
||||
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}));
|
||||
|
||||
{
|
||||
std::ofstream probe{options.project_root / "probe.txt"};
|
||||
probe << "changed\n";
|
||||
Void::Testing::require(probe.good());
|
||||
}
|
||||
|
||||
bool saw_probe = false;
|
||||
for (int attempt = 0; attempt < 100 && !saw_probe; ++attempt) {
|
||||
auto poll = request_object(socket, R"({"op":"watch_poll"})");
|
||||
Void::Testing::require(poll.has_value());
|
||||
for (const auto &path : string_array_field(*poll, "changed")) {
|
||||
if (path.find("probe.txt") != std::string::npos) {
|
||||
saw_probe = true;
|
||||
}
|
||||
}
|
||||
if (!saw_probe) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{20});
|
||||
}
|
||||
}
|
||||
Void::Testing::expect(saw_probe);
|
||||
|
||||
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