feat(daemon): stage installs on request
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 6s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 12s

This commit is contained in:
faumaray committed 2026-12-04 03:09:41 +03:00
1 parent 3f181dc241
commit 2c602fc3e7
8 files changed
+205 -3

No files matched your search

+1
View File
@@ -78,6 +78,7 @@ 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 actions .*--limit" "" daemon actions --help)
check_process(0 "Usage: vbs daemon install .*--prefix" "" daemon install --help)
check_process(0 "Usage: vbs daemon ide wait .*--timeout-ms" "" daemon ide wait --help)
check_process(2 "" "missing subcommand for 'vbs daemon'" daemon)
+51
View File
@@ -1,4 +1,5 @@
#include <Void/Build/Daemon/Daemon.hpp>
#include <Void/Build/Util/Json.hpp>
#include <Void/Data/StrictJson.hpp>
#include <Void/System/TempDir.hpp>
#include <Void/Testing/Assert.hpp>
@@ -1411,6 +1412,56 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(!bool_field(*invalid, "ok", true));
}
VOID_TEST(Daemon, install_stages_prefix_and_writes_manifest) {
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 prefix = temp->path() / "prefix";
const std::string install_request =
std::format(R"({{"op":"install","prefix":{},"package_name":"demo"}})",
Void::Build::Util::json_quote(prefix.string()));
auto installed = request_object(socket, install_request, std::chrono::seconds{120});
auto missing_prefix = request_object(socket, R"({"op":"install"})");
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(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(str_field(*installed, "manifest")));
Void::Testing::require(missing_prefix.has_value());
Void::Testing::expect(!bool_field(*missing_prefix, "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());