feat(registry): support single-range downloads; extend install tests
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 8s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 11s

This commit is contained in:
faumaray committed 2026-12-04 05:28:36 +03:00
1 parent 3fa7ab086f
commit c6436a8010
7 files changed
+345 -17

No files matched your search

+250 -14
View File
@@ -1553,12 +1553,12 @@ void build(Void::Build::Project &project) {
auto listed =
request_object(socket, R"({"op":"actions","limit":5})", std::chrono::seconds{120});
auto filtered = request_object(socket, R"({"op":"actions","target":"nope"})",
std::chrono::seconds{120});
auto by_kind = request_object(socket, R"({"op":"actions","kind":"link"})",
std::chrono::seconds{120});
auto unknown_kind = request_object(socket, R"({"op":"actions","kind":"nope"})",
std::chrono::seconds{120});
auto filtered =
request_object(socket, R"({"op":"actions","target":"nope"})", std::chrono::seconds{120});
auto by_kind =
request_object(socket, R"({"op":"actions","kind":"link"})", std::chrono::seconds{120});
auto unknown_kind =
request_object(socket, R"({"op":"actions","kind":"nope"})", std::chrono::seconds{120});
auto invalid_kind = request_object(socket, R"({"op":"actions","kind":5})");
auto invalid = request_object(socket, R"({"op":"actions","limit":1001})");
auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})");
@@ -1616,7 +1616,7 @@ VOID_TEST(Daemon, install_stages_prefix_and_writes_manifest) {
void build(Void::Build::Project &project) {
auto app = project.executable("app");
app.sources({"main.cpp"}).install("bin");
app.sources({"main.cpp"}).install("bin", "runtime");
}
)cpp";
Void::Testing::require(descriptor.good());
@@ -1650,6 +1650,46 @@ void build(Void::Build::Project &project) {
Void::Testing::require(missing_prefix.has_value());
Void::Testing::expect(!bool_field(*missing_prefix, "ok", true));
const auto prefix_no_cmake = temp->path() / "prefix-no-cmake";
const std::string install_no_cmake_request = std::format(
R"({{"op":"install","prefix":{},"package_name":"demo","package_version":"9.9.9",)"
R"("component":"runtime","export_cmake":false,"export_native":false}})",
Void::Build::Util::json_quote(prefix_no_cmake.string()));
auto installed_no_cmake =
request_object(socket, install_no_cmake_request, std::chrono::seconds{120});
Void::Testing::require(installed_no_cmake.has_value());
Void::Testing::expect(bool_field(*installed_no_cmake, "ok"));
Void::Testing::expect(int_field(*installed_no_cmake, "files") >= 1);
Void::Testing::expect(std::filesystem::exists(prefix_no_cmake / "bin" / "app"));
bool has_cmake_config = false;
for (const auto &entry : std::filesystem::recursive_directory_iterator(prefix_no_cmake)) {
if (entry.is_regular_file() && entry.path().filename().string().ends_with("Config.cmake")) {
has_cmake_config = true;
}
}
Void::Testing::expect(!has_cmake_config);
const std::string uninstall_no_cmake_request =
std::format(R"({{"op":"uninstall","prefix":{}}})",
Void::Build::Util::json_quote(prefix_no_cmake.string()));
auto uninstalled_no_cmake = request_object(socket, uninstall_no_cmake_request);
Void::Testing::require(uninstalled_no_cmake.has_value());
Void::Testing::expect(bool_field(*uninstalled_no_cmake, "ok"));
Void::Testing::expect(int_field(*uninstalled_no_cmake, "removed") >= 1);
const auto empty_prefix = temp->path() / "empty-prefix";
std::filesystem::create_directories(empty_prefix);
const std::string uninstall_empty_request =
std::format(R"({{"op":"uninstall","prefix":{}}})",
Void::Build::Util::json_quote(empty_prefix.string()));
auto uninstalled_empty = request_object(socket, uninstall_empty_request);
Void::Testing::require(uninstalled_empty.has_value());
if (bool_field(*uninstalled_empty, "ok")) {
Void::Testing::expect_eq(int_field(*uninstalled_empty, "removed"), std::int64_t{0});
} else {
Void::Testing::expect(field(*uninstalled_empty, "error") != nullptr);
}
const std::string uninstall_request = std::format(
R"({{"op":"uninstall","prefix":{}}})", Void::Build::Util::json_quote(prefix.string()));
auto uninstalled = request_object(socket, uninstall_request);
@@ -1664,6 +1704,202 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(!std::filesystem::exists(prefix / "bin" / "app"));
}
VOID_TEST(Daemon, install_request_component_filters_installed_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"}).install("bin", "runtime");
auto tool = project.executable("tool");
tool.sources({"tool.cpp"}).install("bin", "tools");
}
)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());
}
{
std::ofstream source{options.project_root / "tool.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}));
const auto prefix = temp->path() / "component-prefix";
const std::string install_request =
std::format(R"({{"op":"install","prefix":{},"package_name":"demo","component":"runtime"}})",
Void::Build::Util::json_quote(prefix.string()));
auto installed = request_object(socket, install_request, std::chrono::seconds{120});
const std::string invalid_prefix =
Void::Build::Util::json_quote((temp->path() / "invalid-prefix").string());
auto empty_component = request_object(
socket, std::format(R"({{"op":"install","prefix":{},"component":""}})", invalid_prefix));
auto numeric_component = request_object(
socket, std::format(R"({{"op":"install","prefix":{},"component":5}})", invalid_prefix));
Void::Testing::require(installed.has_value());
Void::Testing::expect(bool_field(*installed, "ok"));
Void::Testing::expect(int_field(*installed, "files") >= 1);
Void::Testing::expect(std::filesystem::exists(prefix / "bin" / "app"));
Void::Testing::expect(!std::filesystem::exists(prefix / "bin" / "tool"));
Void::Testing::expect(std::filesystem::exists(str_field(*installed, "manifest")));
Void::Testing::require(empty_component.has_value());
Void::Testing::expect(!bool_field(*empty_component, "ok", true));
Void::Testing::expect(str_field(*empty_component, "error").find("component") !=
std::string::npos);
Void::Testing::require(numeric_component.has_value());
Void::Testing::expect(!bool_field(*numeric_component, "ok", true));
Void::Testing::expect(str_field(*numeric_component, "error").find("component") !=
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::Testing::expect(!std::filesystem::exists(socket));
}
VOID_TEST(Daemon, install_request_can_disable_cmake_and_native_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"}).install("bin");
}
)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}));
const auto full_prefix = temp->path() / "full-prefix";
const std::string full_request =
std::format(R"({{"op":"install","prefix":{},"package_name":"demo"}})",
Void::Build::Util::json_quote(full_prefix.string()));
auto full = request_object(socket, full_request, std::chrono::seconds{120});
const auto lean_prefix = temp->path() / "lean-prefix";
const std::string lean_request = std::format(
R"({{"op":"install","prefix":{},"package_name":"demo","export_cmake":false,"export_native":false}})",
Void::Build::Util::json_quote(lean_prefix.string()));
auto lean = request_object(socket, lean_request, std::chrono::seconds{120});
const std::string invalid_prefix =
Void::Build::Util::json_quote((temp->path() / "invalid-prefix").string());
auto bad_cmake =
request_object(socket, std::format(R"({{"op":"install","prefix":{},"export_cmake":"no"}})",
invalid_prefix));
auto bad_native = request_object(
socket, std::format(R"({{"op":"install","prefix":{},"export_native":1}})", invalid_prefix));
Void::Testing::require(full.has_value());
Void::Testing::expect(bool_field(*full, "ok"));
Void::Testing::expect(
std::filesystem::exists(full_prefix / "lib" / "cmake" / "demo" / "demoConfig.cmake"));
Void::Testing::expect(
std::filesystem::exists(full_prefix / "share" / "vbs" / "demo" / "package.json"));
Void::Testing::require(lean.has_value());
Void::Testing::expect(bool_field(*lean, "ok"));
Void::Testing::expect(std::filesystem::exists(lean_prefix / "bin" / "app"));
Void::Testing::expect(std::filesystem::exists(str_field(*lean, "manifest")));
Void::Testing::expect(!std::filesystem::exists(lean_prefix / "lib"));
Void::Testing::expect(!std::filesystem::exists(lean_prefix / "share" / "vbs" / "demo"));
Void::Testing::require(bad_cmake.has_value());
Void::Testing::expect(!bool_field(*bad_cmake, "ok", true));
Void::Testing::expect(str_field(*bad_cmake, "error").find("export flags must be booleans") !=
std::string::npos);
Void::Testing::require(bad_native.has_value());
Void::Testing::expect(!bool_field(*bad_native, "ok", true));
Void::Testing::expect(str_field(*bad_native, "error").find("export flags must be booleans") !=
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::Testing::expect(!std::filesystem::exists(socket));
}
VOID_TEST(Daemon, uninstall_request_on_empty_prefix_reports_missing_manifest) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());
const auto options = make_options(temp->path());
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}));
const auto empty = temp->path() / "empty-prefix";
std::filesystem::create_directories(empty);
const std::string uninstall_empty_request = std::format(
R"({{"op":"uninstall","prefix":{}}})", Void::Build::Util::json_quote(empty.string()));
auto empty_uninstall = request_object(socket, uninstall_empty_request);
auto empty_prefix = request_object(socket, R"({"op":"uninstall","prefix":""})");
auto missing_prefix = request_object(socket, R"({"op":"uninstall"})");
auto numeric_prefix = request_object(socket, R"({"op":"uninstall","prefix":5})");
Void::Testing::require(empty_uninstall.has_value());
Void::Testing::expect(!bool_field(*empty_uninstall, "ok", true));
Void::Testing::expect(str_field(*empty_uninstall, "error").find("no VBS install manifest") !=
std::string::npos);
Void::Testing::expect(std::filesystem::exists(empty));
Void::Testing::require(empty_prefix.has_value());
Void::Testing::expect(!bool_field(*empty_prefix, "ok", true));
Void::Testing::require(missing_prefix.has_value());
Void::Testing::expect(!bool_field(*missing_prefix, "ok", true));
Void::Testing::require(numeric_prefix.has_value());
Void::Testing::expect(!bool_field(*numeric_prefix, "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::Testing::expect(!std::filesystem::exists(socket));
}
VOID_TEST(Daemon, gen_tests_generates_registration_unit_confined) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());
@@ -1779,9 +2015,9 @@ void build(Void::Build::Project &project) {
auto all = request_object(socket, R"({"op":"target_flags","target":"app"})",
std::chrono::seconds{120});
auto filtered = request_object(
socket, R"({"op":"target_flags","target":"app","file":"nope.cpp"})",
std::chrono::seconds{120});
auto filtered =
request_object(socket, R"({"op":"target_flags","target":"app","file":"nope.cpp"})",
std::chrono::seconds{120});
auto unknown = request_object(socket, R"({"op":"target_flags","target":"nope"})",
std::chrono::seconds{120});
auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})");
@@ -1973,10 +2209,10 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(describe_raw->find("\"name\":\"lib\"") != std::string::npos);
Void::Testing::expect(describe_raw->find("\"name\":\"app\"") != std::string::npos);
auto member_raw = Void::Build::Daemon::request(
socket, R"({"op":"describe","member":"app"})", std::chrono::seconds{120});
auto unknown_member = request_object(socket, R"({"op":"describe","member":"nope"})",
std::chrono::seconds{120});
auto member_raw = Void::Build::Daemon::request(socket, R"({"op":"describe","member":"app"})",
std::chrono::seconds{120});
auto unknown_member =
request_object(socket, R"({"op":"describe","member":"nope"})", std::chrono::seconds{120});
auto workspace_build =
Void::Build::Daemon::request(socket, R"({"op":"build"})", std::chrono::seconds{120});