feat(daemon): scaffold projects on request
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 9s

This commit is contained in:
faumaray committed 2026-12-04 03:50:09 +03:00
1 parent 2c6b60453a
commit 7945db9497
13 files changed
+365 -130

No files matched your search

+1
View File
@@ -81,6 +81,7 @@ 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 uninstall .*--prefix" "" daemon uninstall --help)
check_process(0 "Usage: vbs daemon gen-tests .*--input.*--output-dir" "" daemon gen-tests --help)
check_process(0 "Usage: vbs daemon init .*--dir" "" daemon init --help)
check_process(0 "Usage: vbs daemon ide wait .*--timeout-ms" "" daemon ide wait --help)
check_process(2 "" "missing subcommand for 'vbs daemon'" daemon)
+38
View File
@@ -1516,6 +1516,44 @@ VOID_TEST(Daemon, gen_tests_generates_registration_unit_confined) {
Void::Testing::expect(!bool_field(*escaped_output, "ok", true));
}
VOID_TEST(Daemon, init_scaffolds_project_confined_to_root) {
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}));
auto created = request_object(socket, R"({"op":"init","dir":"newapp","name":"demo"})");
auto created_again = request_object(socket, R"({"op":"init","dir":"newapp"})");
auto forced = request_object(socket, R"({"op":"init","dir":"newapp","force":true})");
auto escaped = request_object(socket, R"({"op":"init","dir":"../outside"})");
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(created.has_value());
Void::Testing::expect(bool_field(*created, "ok"));
Void::Testing::expect_eq(str_field(*created, "name"), std::string{"demo"});
Void::Testing::expect(!string_array_field(*created, "written").empty());
const auto app_dir = options.project_root / "newapp";
Void::Testing::expect(std::filesystem::exists(app_dir / "build.cpp"));
Void::Testing::expect(std::filesystem::exists(app_dir / "src" / "main.cpp"));
Void::Testing::require(created_again.has_value());
Void::Testing::expect(!bool_field(*created_again, "ok", true));
Void::Testing::require(forced.has_value());
Void::Testing::expect(bool_field(*forced, "ok"));
Void::Testing::require(escaped.has_value());
Void::Testing::expect(!bool_field(*escaped, "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());