feat(daemon): clean generated build outputs on request
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 8s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 21s

This commit is contained in:
faumaray committed 2026-12-04 02:10:53 +03:00
1 parent 7fdda96553
commit cf06b427b7
13 files changed
+198 -25

No files matched your search

+1
View File
@@ -72,6 +72,7 @@ check_process(0 "Usage: vbs daemon ide configs " "" daemon ide configs --help)
check_process(0 "Usage: vbs daemon compdb generations .*--profile" "" daemon compdb generations --help)
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 ide wait .*--timeout-ms" "" daemon ide wait --help)
check_process(2 "" "missing subcommand for 'vbs daemon'" daemon)
+55
View File
@@ -1198,6 +1198,61 @@ VOID_TEST(Daemon, info_reports_daemon_paths_and_host) {
Void::Testing::expect_eq(str_field(*info, "socket"), socket.string());
}
VOID_TEST(Daemon, clean_removes_profile_outputs_and_preserves_cache) {
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"});
}
)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}));
auto build = request_object(socket, R"({"op":"build"})", std::chrono::seconds{120});
Void::Testing::require(build.has_value());
Void::Testing::expect(bool_field(*build, "ok"));
const auto profiles_dir = options.build_root / "profiles";
Void::Testing::expect(std::filesystem::exists(profiles_dir));
const auto cache_dir = options.build_root / ".vbs";
Void::Testing::expect(std::filesystem::exists(cache_dir));
auto cleaned = request_object(socket, R"({"op":"clean"})");
Void::Testing::require(cleaned.has_value());
Void::Testing::expect(bool_field(*cleaned, "ok"));
Void::Testing::expect(int_field(*cleaned, "removed_paths") >= 1);
Void::Testing::expect(!std::filesystem::exists(profiles_dir));
Void::Testing::expect(std::filesystem::exists(cache_dir));
auto invalid = request_object(socket, R"({"op":"clean","all":"yes"})");
Void::Testing::require(invalid.has_value());
Void::Testing::expect(!bool_field(*invalid, "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_TEST(Daemon, describe_empty_project_reports_zero_targets) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());