feat(registry,daemon): answer HEAD without a body; mark editor generations stale
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 11s

This commit is contained in:
faumaray committed 2026-12-04 05:16:57 +03:00
1 parent 2c4eeba945
commit 3fa7ab086f
8 files changed
+190 -2

No files matched your search

+93
View File
@@ -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());
+18
View File
@@ -272,6 +272,17 @@ VOID_TEST(RegistryTests, registry_rbac_immutability_csrf_xss_web_and_backup_rest
auto anon_dl = send_loopback_http(port, "GET", "/api/v1/packages/secret-pkg/1.0.0/download");
Void::Testing::expect(anon_dl.has_value() && anon_dl->status == 401);
// HEAD returns the GET headers (including Content-Length) without a body.
auto head_dl = send_loopback_http(port, "HEAD", "/api/v1/packages/secret-pkg/1.0.0/download",
{{"Authorization", "Bearer " + *alice_tok}});
Void::Testing::expect(head_dl.has_value() && head_dl->status == 200);
if (head_dl) {
Void::Testing::expect(head_dl->body.empty());
Void::Testing::expect(head_dl->headers.contains("content-length"));
Void::Testing::expect(head_dl->headers.at("content-length") != "0");
Void::Testing::expect(head_dl->headers.contains("x-content-sha256"));
}
// Idempotent same-bytes republish -> 200 OK!
auto idemp = send_loopback_http(
port, "PUT", "/api/v1/packages/secret-pkg/1.0.0",
@@ -846,6 +857,13 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
if (downloaded) {
Void::Testing::expect(downloaded->body == artifact);
}
auto head_binary = send_loopback_http(port, "HEAD", binary_path + "/download");
Void::Testing::expect(head_binary.has_value() && head_binary->status == 200);
if (head_binary) {
Void::Testing::expect(head_binary->body.empty());
Void::Testing::expect_eq(head_binary->headers.at("content-length"),
std::to_string(artifact.size()));
}
auto conflict = send_loopback_http(
port, "PUT", binary_path,