feat(daemon): build and run declared test targets
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 18s

This commit is contained in:
faumaray committed 2026-12-03 22:47:12 +03:00
1 parent ae57ee7666
commit afea6f3fad
9 files changed
+177 -21

No files matched your search

+56
View File
@@ -853,6 +853,62 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(!bool_field(*invalid, "ok", true));
}
VOID_TEST(Daemon, test_builds_and_runs_declared_tests) {
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) {
project.test("good_test")
.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"good.cpp"});
project.test("bad_test")
.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"bad.cpp"});
}
)cpp";
Void::Testing::require(descriptor.good());
}
{
std::ofstream source{options.project_root / "good.cpp"};
source << "int main() { return 0; }\n";
Void::Testing::require(source.good());
}
{
std::ofstream source{options.project_root / "bad.cpp"};
source << "int main() { return 3; }\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 raw = Void::Build::Daemon::request(socket, R"({"op":"test"})", std::chrono::seconds{300});
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(raw.has_value());
const auto parsed = parse_json(*raw);
Void::Testing::require(parsed.has_value());
const auto *object = as_object(*parsed);
Void::Testing::require(object != nullptr);
Void::Testing::expect_eq(str_field(*object, "op"), std::string{"test"});
Void::Testing::expect(!bool_field(*object, "ok", true));
Void::Testing::expect_eq(int_field(*object, "tests_passed"), std::int64_t{1});
Void::Testing::expect_eq(int_field(*object, "tests_failed"), std::int64_t{1});
}
VOID_TEST(Daemon, describe_empty_project_reports_zero_targets) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());