[M4] add cargoxx run/test/clean
This commit is contained in:
36
src/cli/cmd_test.cpp
Normal file
36
src/cli/cmd_test.cpp
Normal 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
|
||||
Reference in New Issue
Block a user