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

+14 -5
View File
@@ -1608,21 +1608,22 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
R"({{"op":"ide_query","profile":{}{}}})", Util::json_quote(opts.profile_arg),
opts.member_arg ? std::format(",\"member\":{}", Util::json_quote(*opts.member_arg))
: std::string{});
} else if (sub == "build") {
} else if (sub == "build" || sub == "test") {
std::size_t jobs = 0;
const auto [ptr, ec] = std::from_chars(opts.jobs_arg.data(),
opts.jobs_arg.data() + opts.jobs_arg.size(), jobs);
if (ec != std::errc{} || ptr != opts.jobs_arg.data() + opts.jobs_arg.size() || jobs > 256) {
std::cerr << "vbs daemon build: invalid --jobs value '" << opts.jobs_arg << "'\n";
std::cerr << "vbs daemon " << sub << ": invalid --jobs value '" << opts.jobs_arg
<< "'\n";
return 2;
}
if (opts.profile_arg.empty()) {
std::cerr << "vbs daemon build: --profile must not be empty\n";
std::cerr << "vbs daemon " << sub << ": --profile must not be empty\n";
return 2;
}
const std::string targets_json = Util::json_array(
opts.targets, [](const std::string &target) { return Util::json_quote(target); });
request_json = std::format(R"({{"op":"build","profile":{},"targets":{},"jobs":{}}})",
request_json = std::format(R"({{"op":"{}","profile":{},"targets":{},"jobs":{}}})", sub,
Util::json_quote(opts.profile_arg), targets_json, jobs);
} else {
std::cerr << "vbs daemon: unknown command '" << sub << "'\n";
@@ -1632,7 +1633,7 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
// Describe evaluates the whole project graph (descriptor compile, toolchain probe, lowering),
// which can exceed the 2 s default; the daemon bounds evaluation at 10 s.
const auto request_timeout =
sub == "build" ? std::chrono::milliseconds{std::chrono::hours{1}}
(sub == "build" || sub == "test") ? std::chrono::milliseconds{std::chrono::hours{1}}
: (sub == "watch_poll" || sub == "editor_status") ? std::chrono::milliseconds{5000}
: sub == "compdb_use" ? std::chrono::milliseconds{10000}
: sub == "watch_wait" ? std::chrono::milliseconds{10000}
@@ -2618,6 +2619,14 @@ int main(int argc, char **argv) {
.option_many("--target", "-t", "Target to build", daemon_opts.targets)
.option_default("--jobs", "-j", "Maximum parallel jobs (0 = hardware concurrency)",
daemon_opts.jobs_arg, "0");
auto &daemon_test_cmd =
daemon_cmd.subcommand("test", "Build and run declared test targets via the daemon");
configure_daemon_common(daemon_test_cmd);
daemon_test_cmd
.option_default("--profile", "-p", "Profile to build", daemon_opts.profile_arg, "debug")
.option_many("--target", "-t", "Target to build/test", daemon_opts.targets)
.option_default("--jobs", "-j", "Maximum parallel jobs (0 = hardware concurrency)",
daemon_opts.jobs_arg, "0");
auto &daemon_compdb_cmd =
daemon_cmd.subcommand("compdb", "Editor compilation database served by the daemon");
auto &daemon_compdb_use_cmd =