feat(registry,daemon): honour If-None-Match; allow offline deps resolution
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 10s

This commit is contained in:
faumaray committed 2026-12-04 05:44:26 +03:00
1 parent c6436a8010
commit fdfab9277b
8 files changed
+140 -19

No files matched your search

+65
View File
@@ -438,6 +438,22 @@ void build(Void::Build::Project &project) {
Void::Testing::expect_eq(str_field(*first_dep, "source_kind"), std::string{"path"});
Void::Testing::expect(!str_field(*first_dep, "sha256").empty());
auto offline_deps =
request_object(socket, R"({"op":"deps","offline":true})", std::chrono::seconds{120});
Void::Testing::require(offline_deps.has_value());
Void::Testing::expect(bool_field(*offline_deps, "ok"));
Void::Testing::expect_eq(str_field(*offline_deps, "op"), std::string{"deps"});
const auto *offline_entries = field(*offline_deps, "entries");
Void::Testing::require(offline_entries != nullptr);
const auto *offline_array = std::get_if<JsonValue::Array>(&offline_entries->value);
Void::Testing::require(offline_array != nullptr && !offline_array->empty());
auto invalid_offline = request_object(socket, R"({"op":"deps","offline":"yes"})");
Void::Testing::require(invalid_offline.has_value());
Void::Testing::expect(!bool_field(*invalid_offline, "ok", true));
Void::Testing::expect(str_field(*invalid_offline, "error").find("boolean") !=
std::string::npos);
auto build = request_object(socket, R"({"op":"build"})", std::chrono::seconds{120});
Void::Testing::require(build.has_value());
Void::Testing::expect(bool_field(*build, "ok"));
@@ -451,6 +467,55 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(run_result.has_value());
}
VOID_TEST(Daemon, deps_offline_reports_uncached_registry_dependency) {
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) {
project.dependency("remote")
.package("remote-pkg", "^1.0")
.registry("http://127.0.0.1:1");
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}));
// The package is not in the lock or cache, so offline resolution must fail before any
// registry connection is attempted; a network error would mean `offline` was ignored.
auto offline =
request_object(socket, R"({"op":"deps","offline":true})", std::chrono::seconds{120});
Void::Testing::require(offline.has_value());
Void::Testing::expect(!bool_field(*offline, "ok", true));
Void::Testing::expect(
str_field(*offline, "error").find("offline mode cannot query live package registry") !=
std::string::npos);
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, ide_query_serves_workspace_targets_and_compdb) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());
+21 -6
View File
@@ -824,6 +824,20 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
}
auto missing_release = send_loopback_http(port, "GET", "/api/v1/packages/demo-bin/9.9.9");
Void::Testing::expect(missing_release.has_value() && missing_release->status == 404);
// Conditional requests: the ETag of a read response enables a bodyless 304.
if (release_detail) {
const auto etag_it = release_detail->headers.find("etag");
Void::Testing::expect(etag_it != release_detail->headers.end());
if (etag_it != release_detail->headers.end()) {
auto not_modified = send_loopback_http(port, "GET", "/api/v1/packages/demo-bin/1.0.0",
{{"If-None-Match", etag_it->second}});
Void::Testing::expect(not_modified.has_value() && not_modified->status == 304);
if (not_modified) {
Void::Testing::expect(not_modified->body.empty());
}
}
}
if (missing_release) {
Void::Testing::expect(missing_release->body.find("release not found") != std::string::npos);
}
@@ -857,16 +871,17 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
if (downloaded) {
Void::Testing::expect(downloaded->body == artifact);
}
auto ranged = send_loopback_http(port, "GET", binary_path + "/download",
{{"Range", "bytes=0-3"}});
auto ranged =
send_loopback_http(port, "GET", binary_path + "/download", {{"Range", "bytes=0-3"}});
Void::Testing::expect(ranged.has_value() && ranged->status == 206);
if (ranged) {
Void::Testing::expect_eq(ranged->body, artifact.substr(0, 4));
Void::Testing::expect(ranged->headers.at("content-range").find("/" +
std::to_string(artifact.size())) != std::string::npos);
Void::Testing::expect(
ranged->headers.at("content-range").find("/" + std::to_string(artifact.size())) !=
std::string::npos);
}
auto unsatisfiable = send_loopback_http(port, "GET", binary_path + "/download",
{{"Range", "bytes=999999-"}});
auto unsatisfiable =
send_loopback_http(port, "GET", binary_path + "/download", {{"Range", "bytes=999999-"}});
Void::Testing::expect(unsatisfiable.has_value() && unsatisfiable->status == 416);
auto head_binary = send_loopback_http(port, "HEAD", binary_path + "/download");
Void::Testing::expect(head_binary.has_value() && head_binary->status == 200);