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 overlay_path) -> util::Result { 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", {"--extra-experimental-features", "nix-command flakes", "develop", "path:./build", "--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