feat(daemon): pack the project into a confined source archive
This commit is contained in:
1 parent
3a3376c331
commit
69d1a8d274
8 files changed
+101
-2
No files matched your search
@@ -74,6 +74,7 @@ check_process(0 "Usage: vbs daemon deps .*--profile" "" daemon deps --help)
|
||||
check_process(0 "Usage: vbs daemon info " "" daemon info --help)
|
||||
check_process(0 "Usage: vbs daemon clean " "" daemon clean --help)
|
||||
check_process(0 "Usage: vbs daemon target info .*--name" "" daemon target info --help)
|
||||
check_process(0 "Usage: vbs daemon pack .*--output" "" daemon pack --help)
|
||||
check_process(0 "Usage: vbs daemon ide wait .*--timeout-ms" "" daemon ide wait --help)
|
||||
check_process(2 "" "missing subcommand for 'vbs daemon'" daemon)
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user