[M4] add cargoxx run/test/clean

This commit is contained in:
2026-05-10 00:12:25 +00:00
parent f6e8699a72
commit 0a398d1c31
10 changed files with 349 additions and 0 deletions

36
src/cli/cmd_test.cpp Normal file
View File

@@ -0,0 +1,36 @@
module cargoxx.cli;
import std;
import cargoxx.util;
import cargoxx.exec;
namespace cargoxx::cli {
namespace fs = std::filesystem;
auto cmd_test(const fs::path& project_root, bool release,
std::optional<fs::path> overlay_path) -> util::Result<int> {
if (auto r = cmd_build(project_root, false, release, std::nullopt, std::move(overlay_path));
!r) {
return std::unexpected(r.error());
}
const std::string profile = release ? "release" : "debug";
const auto build_dir = std::format("build/{}", profile);
auto r = exec::run("nix",
{"develop", "--command", "ctest", "--test-dir", build_dir,
"--output-on-failure"},
exec::ExecOptions{
.cwd = project_root,
.env_overrides = {},
.timeout = std::nullopt,
.inherit_stdio = true,
});
if (!r) {
return std::unexpected(r.error());
}
return r->exit_code;
}
} // namespace cargoxx::cli