feat(daemon): report editor selection and compdb status
This commit is contained in:
1 parent
1a884fd931
commit
343e03c27c
9 files changed
+140
-6
No files matched your search
@@ -679,6 +679,64 @@ VOID_TEST(Daemon, watch_wait_long_polls_until_change_and_times_out) {
|
||||
Void::Testing::expect(run_result.has_value());
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, editor_status_reports_selection_after_compdb_export) {
|
||||
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 empty = request_object(socket, R"({"op":"editor_status"})");
|
||||
Void::Testing::require(empty.has_value());
|
||||
Void::Testing::expect(bool_field(*empty, "ok"));
|
||||
Void::Testing::expect(field(*empty, "selection") != nullptr);
|
||||
Void::Testing::expect(!bool_field(*empty, "compdb_exists", true));
|
||||
|
||||
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 status = request_object(socket, R"({"op":"editor_status"})");
|
||||
Void::Testing::require(status.has_value());
|
||||
Void::Testing::expect(bool_field(*status, "ok"));
|
||||
Void::Testing::expect(bool_field(*status, "compdb_exists"));
|
||||
Void::Testing::expect(int_field(*status, "compdb_entries") >= 1);
|
||||
const auto *selection = field(*status, "selection");
|
||||
Void::Testing::require(selection != nullptr);
|
||||
const auto *selection_object = as_object(*selection);
|
||||
Void::Testing::require(selection_object != nullptr);
|
||||
Void::Testing::expect_eq(str_field(*selection_object, "profile"), std::string{"debug"});
|
||||
Void::Testing::expect(!str_field(*selection_object, "compdb_path").empty());
|
||||
|
||||
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