feat(daemon): report editor configuration file presence
This commit is contained in:
1 parent
ca9ad1158a
commit
ba682e8bd1
8 files changed
+127
-2
No files matched your search
@@ -1021,6 +1021,73 @@ VOID_TEST(Daemon, workspace_members_lists_declared_members) {
|
||||
Void::Testing::expect(raw->find("packages/lib") != std::string::npos);
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, ide_configs_reports_generated_files) {
|
||||
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 before = request_object(socket, R"({"op":"ide_configs"})");
|
||||
Void::Testing::require(before.has_value());
|
||||
Void::Testing::expect(bool_field(*before, "ok"));
|
||||
Void::Testing::expect(!std::filesystem::exists(options.project_root / ".clangd"));
|
||||
|
||||
auto generated =
|
||||
request_object(socket, R"({"op":"ide_generate","editor":"clangd","force":true})",
|
||||
std::chrono::seconds{120});
|
||||
Void::Testing::require(generated.has_value());
|
||||
Void::Testing::expect(bool_field(*generated, "ok"));
|
||||
|
||||
auto after = request_object(socket, R"({"op":"ide_configs"})");
|
||||
Void::Testing::require(after.has_value());
|
||||
Void::Testing::expect(bool_field(*after, "ok"));
|
||||
const auto *configs = field(*after, "configs");
|
||||
Void::Testing::require(configs != nullptr);
|
||||
const auto *config_array = std::get_if<JsonValue::Array>(&configs->value);
|
||||
Void::Testing::require(config_array != nullptr);
|
||||
bool saw_clangd = false;
|
||||
for (const auto &item : *config_array) {
|
||||
const auto *entry = std::get_if<JsonObject>(&item.value);
|
||||
if (entry == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (str_field(*entry, "editor") == "clangd") {
|
||||
saw_clangd = true;
|
||||
Void::Testing::expect(bool_field(*entry, "exists"));
|
||||
}
|
||||
}
|
||||
Void::Testing::expect(saw_clangd);
|
||||
|
||||
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