feat(daemon): pack the project into a confined source archive
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 18s

This commit is contained in:
faumaray committed 2026-12-04 02:32:52 +03:00
1 parent 3a3376c331
commit 69d1a8d274
8 files changed
+101 -2

No files matched your search

+43
View File
@@ -1307,6 +1307,49 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(!bool_field(*missing, "ok", true));
}
VOID_TEST(Daemon, pack_creates_archive_confined_to_build_root) {
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) {}
)cpp";
Void::Testing::require(descriptor.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 packed = request_object(socket, R"({"op":"pack","output":"dist/src.tar"})");
auto escaped = request_object(socket, R"({"op":"pack","output":"../../escape.tar"})");
auto invalid = request_object(socket, R"({"op":"pack","output":5})");
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::require(packed.has_value());
Void::Testing::expect(bool_field(*packed, "ok"));
const std::string archive = str_field(*packed, "archive");
Void::Testing::expect(archive.ends_with("dist/src.tar"));
Void::Testing::expect(std::filesystem::exists(archive));
Void::Testing::expect_eq(str_field(*packed, "sha256").size(), std::size_t{64});
Void::Testing::require(escaped.has_value());
Void::Testing::expect(!bool_field(*escaped, "ok", true));
Void::Testing::require(invalid.has_value());
Void::Testing::expect(!bool_field(*invalid, "ok", true));
}
VOID_TEST(Daemon, describe_empty_project_reports_zero_targets) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());