feat(registry,daemon): answer HEAD without a body; mark editor generations stale
This commit is contained in:
1 parent
2c4eeba945
commit
3fa7ab086f
8 files changed
+190
-2
No files matched your search
@@ -1172,6 +1172,99 @@ void build(Void::Build::Project &project) {
|
||||
Void::Testing::expect(!bool_field(*invalid, "ok", true));
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, compdb_stale_marks_generation_stale) {
|
||||
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"));
|
||||
|
||||
std::string generation_id;
|
||||
{
|
||||
auto valid = request_object(socket, R"({"op":"compdb_generations","profile":"debug"})",
|
||||
std::chrono::seconds{120});
|
||||
Void::Testing::require(valid.has_value());
|
||||
Void::Testing::expect(bool_field(*valid, "ok"));
|
||||
const auto *generations = field(*valid, "generations");
|
||||
Void::Testing::require(generations != nullptr);
|
||||
const auto *array = std::get_if<JsonValue::Array>(&generations->value);
|
||||
Void::Testing::require(array != nullptr && !array->empty());
|
||||
const auto *first = std::get_if<JsonObject>(&array->front().value);
|
||||
Void::Testing::require(first != nullptr);
|
||||
Void::Testing::expect_eq(str_field(*first, "status"), std::string{"valid"});
|
||||
generation_id = str_field(*first, "id");
|
||||
}
|
||||
|
||||
auto stale =
|
||||
request_object(socket, R"({"op":"compdb_stale","profile":"debug","reason":"manual"})");
|
||||
Void::Testing::require(stale.has_value());
|
||||
Void::Testing::expect(bool_field(*stale, "ok"));
|
||||
Void::Testing::expect_eq(str_field(*stale, "op"), std::string{"compdb_stale"});
|
||||
Void::Testing::expect_eq(str_field(*stale, "profile"), std::string{"debug"});
|
||||
Void::Testing::expect_eq(str_field(*stale, "status"), std::string{"stale"});
|
||||
|
||||
{
|
||||
auto refreshed = request_object(socket, R"({"op":"compdb_generations","profile":"debug"})",
|
||||
std::chrono::seconds{120});
|
||||
Void::Testing::require(refreshed.has_value());
|
||||
Void::Testing::expect(bool_field(*refreshed, "ok"));
|
||||
const auto *generations = field(*refreshed, "generations");
|
||||
Void::Testing::require(generations != nullptr);
|
||||
const auto *array = std::get_if<JsonValue::Array>(&generations->value);
|
||||
Void::Testing::require(array != nullptr && !array->empty());
|
||||
const auto *first = std::get_if<JsonObject>(&array->front().value);
|
||||
Void::Testing::require(first != nullptr);
|
||||
Void::Testing::expect_eq(str_field(*first, "id"), generation_id);
|
||||
Void::Testing::expect_eq(str_field(*first, "status"), std::string{"stale"});
|
||||
Void::Testing::expect(str_field(*first, "diagnostic").find("manual") != std::string::npos);
|
||||
}
|
||||
|
||||
auto invalid_profile = request_object(socket, R"({"op":"compdb_stale","profile":"../x"})");
|
||||
Void::Testing::require(invalid_profile.has_value());
|
||||
Void::Testing::expect(!bool_field(*invalid_profile, "ok", true));
|
||||
|
||||
auto missing_profile = request_object(socket, R"({"op":"compdb_stale"})");
|
||||
Void::Testing::require(missing_profile.has_value());
|
||||
Void::Testing::expect(!bool_field(*missing_profile, "ok", true));
|
||||
|
||||
auto invalid_reason =
|
||||
request_object(socket, R"({"op":"compdb_stale","profile":"debug","reason":1})");
|
||||
Void::Testing::require(invalid_reason.has_value());
|
||||
Void::Testing::expect(!bool_field(*invalid_reason, "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, info_reports_daemon_paths_and_host) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
|
||||
Reference in new issue
Block a user