use std::process::Command;
use anyhow::{Context, Result};
use clap::Parser;
use crate::ui;
#[derive(Debug, Parser)]
pub struct TestArgs {
#[arg(last = true)]
pub cargo_args: Vec<String>,
}
pub fn run(args: TestArgs) -> Result<()> {
ui::header(
"portaki test",
"Forward to cargo test — the module's own tests, on the host target.",
);
let mut cmd = Command::new("cargo");
cmd.arg("test");
for arg in &args.cargo_args {
cmd.arg(arg);
}
let status = cmd.status().context("cargo test")?;
ui::blank();
if status.success() {
ui::success("tests passed");
ui::blank();
Ok(())
} else {
anyhow::bail!("cargo test failed");
}
}