2026-05-21 19:48:02 +00:00
|
|
|
use std::process::{Command, ExitCode};
|
2026-07-07 10:40:02 +00:00
|
|
|
use std::time::Instant;
|
2026-02-15 17:03:31 +00:00
|
|
|
|
|
|
|
|
struct TestStep {
|
|
|
|
|
label: &'static str,
|
|
|
|
|
args: &'static [&'static str],
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-25 12:30:18 +00:00
|
|
|
const BASIC_TESTS: &[TestStep] = &[
|
|
|
|
|
TestStep {
|
|
|
|
|
label: "root crate",
|
|
|
|
|
args: &["test"],
|
|
|
|
|
},
|
|
|
|
|
TestStep {
|
|
|
|
|
label: "datastream",
|
|
|
|
|
args: &["test", "-p", "datastream"],
|
|
|
|
|
},
|
|
|
|
|
TestStep {
|
|
|
|
|
label: "distribution",
|
|
|
|
|
args: &["test", "-p", "distribution"],
|
|
|
|
|
},
|
|
|
|
|
TestStep {
|
|
|
|
|
label: "iroh-driver",
|
|
|
|
|
args: &["test", "-p", "iroh-driver"],
|
|
|
|
|
},
|
|
|
|
|
TestStep {
|
|
|
|
|
label: "mvp-system",
|
|
|
|
|
args: &["test", "-p", "mvp-system"],
|
|
|
|
|
},
|
|
|
|
|
TestStep {
|
|
|
|
|
label: "swactor-process",
|
|
|
|
|
args: &["test", "-p", "swactor-process"],
|
|
|
|
|
},
|
|
|
|
|
TestStep {
|
|
|
|
|
label: "swactor-transport",
|
|
|
|
|
args: &["test", "-p", "swactor-transport"],
|
|
|
|
|
},
|
|
|
|
|
TestStep {
|
|
|
|
|
label: "dashboard",
|
|
|
|
|
args: &["test", "-p", "dashboard"],
|
|
|
|
|
},
|
|
|
|
|
TestStep {
|
|
|
|
|
label: "swactor-vastai",
|
|
|
|
|
args: &["test", "-p", "swactor-vastai"],
|
|
|
|
|
},
|
|
|
|
|
TestStep {
|
|
|
|
|
label: "xtask",
|
|
|
|
|
args: &["test", "-p", "xtask"],
|
|
|
|
|
},
|
|
|
|
|
];
|
2026-02-24 09:12:28 +00:00
|
|
|
|
2026-06-25 12:30:18 +00:00
|
|
|
fn cargo_bin() -> String {
|
|
|
|
|
option_env!("CARGO")
|
|
|
|
|
.map(str::to_string)
|
|
|
|
|
.unwrap_or_else(|| "cargo".to_string())
|
2026-02-15 17:03:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn print_usage() {
|
|
|
|
|
println!(
|
|
|
|
|
"\
|
2026-07-05 09:59:51 +00:00
|
|
|
USAGE: cargo xtask <command>
|
2026-02-15 17:03:31 +00:00
|
|
|
|
2026-06-25 12:30:18 +00:00
|
|
|
COMMANDS:
|
2026-07-07 10:40:02 +00:00
|
|
|
mvp-chat [--vastai] [args...] Run the one-node human chat wrapper against the real orchestrator/worker bins.
|
2026-07-05 09:59:51 +00:00
|
|
|
test Run all basic non-binding tests. This includes the root crate with
|
|
|
|
|
`cargo test` plus each non-binding repository package with `cargo test -p`.
|
|
|
|
|
Feature-gated E2E/bin tests are intentionally excluded."
|
2026-02-15 17:03:31 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-25 12:30:18 +00:00
|
|
|
fn run_step(step: &TestStep) -> bool {
|
|
|
|
|
println!("\n=== {} ===", step.label);
|
|
|
|
|
println!(" cargo {}", step.args.join(" "));
|
|
|
|
|
println!();
|
2026-02-15 17:03:31 +00:00
|
|
|
|
2026-06-25 12:30:18 +00:00
|
|
|
match Command::new(cargo_bin()).args(step.args).status() {
|
|
|
|
|
Ok(status) => status.success(),
|
|
|
|
|
Err(error) => {
|
|
|
|
|
eprintln!("Failed to execute cargo: {error}");
|
|
|
|
|
false
|
2026-02-15 17:03:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-25 12:30:18 +00:00
|
|
|
fn run_tests() -> ExitCode {
|
2026-02-15 17:03:31 +00:00
|
|
|
let start = Instant::now();
|
|
|
|
|
|
2026-06-25 12:30:18 +00:00
|
|
|
for (index, step) in BASIC_TESTS.iter().enumerate() {
|
|
|
|
|
if !run_step(step) {
|
|
|
|
|
eprintln!(
|
|
|
|
|
"\n--- FAILED after {:.1}s ({index} passed, 1 failed) ---",
|
|
|
|
|
start.elapsed().as_secs_f64()
|
|
|
|
|
);
|
|
|
|
|
return ExitCode::from(1);
|
2026-02-15 17:03:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
println!(
|
2026-06-25 12:30:18 +00:00
|
|
|
"\n--- All {} step(s) passed in {:.1}s ---",
|
|
|
|
|
BASIC_TESTS.len(),
|
|
|
|
|
start.elapsed().as_secs_f64()
|
2026-02-15 17:03:31 +00:00
|
|
|
);
|
2026-06-25 12:30:18 +00:00
|
|
|
ExitCode::SUCCESS
|
2026-02-15 17:03:31 +00:00
|
|
|
}
|
2026-02-16 15:39:27 +00:00
|
|
|
|
2026-07-05 09:59:51 +00:00
|
|
|
fn run_mvp_chat(args: Vec<String>) -> ExitCode {
|
2026-07-07 10:40:02 +00:00
|
|
|
let mut command = Command::new(cargo_bin());
|
|
|
|
|
command.args([
|
|
|
|
|
"run",
|
|
|
|
|
"--package",
|
|
|
|
|
"mvp-system",
|
|
|
|
|
"--bin",
|
|
|
|
|
"mvp-one-node-chat",
|
|
|
|
|
"--",
|
|
|
|
|
]);
|
2026-07-05 09:59:51 +00:00
|
|
|
command.args(args);
|
|
|
|
|
|
2026-07-07 10:40:02 +00:00
|
|
|
match command.status() {
|
|
|
|
|
Ok(status) if status.success() => ExitCode::SUCCESS,
|
|
|
|
|
Ok(status) => ExitCode::from(
|
|
|
|
|
status
|
|
|
|
|
.code()
|
|
|
|
|
.and_then(|code| u8::try_from(code).ok())
|
|
|
|
|
.unwrap_or(1),
|
|
|
|
|
),
|
|
|
|
|
Err(error) => {
|
|
|
|
|
eprintln!("Failed to execute cargo mvp-chat: {error}");
|
|
|
|
|
ExitCode::from(1)
|
2026-07-05 09:59:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-21 19:48:02 +00:00
|
|
|
fn main() -> ExitCode {
|
2026-06-25 12:30:18 +00:00
|
|
|
let mut args = std::env::args().skip(1);
|
2026-07-05 09:59:51 +00:00
|
|
|
match args.next().as_deref() {
|
|
|
|
|
Some("test") if args.next().is_none() => run_tests(),
|
|
|
|
|
Some("mvp-chat") => run_mvp_chat(args.collect()),
|
|
|
|
|
Some("help" | "--help" | "-h") | None => {
|
2026-06-25 12:30:18 +00:00
|
|
|
print_usage();
|
2026-05-21 19:48:02 +00:00
|
|
|
ExitCode::SUCCESS
|
|
|
|
|
}
|
2026-06-25 12:30:18 +00:00
|
|
|
_ => {
|
2026-02-24 09:12:28 +00:00
|
|
|
print_usage();
|
2026-05-21 19:48:02 +00:00
|
|
|
ExitCode::from(1)
|
2026-02-16 15:39:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|