use std::process::{Command, Stdio};
use std::thread;
use std::time::{Duration, Instant};
fn pounce_exe() -> std::path::PathBuf {
std::path::PathBuf::from(env!("CARGO_BIN_EXE_pounce"))
}
#[test]
fn mlsl_terminates_on_single_minimum_problem() {
const TIMEOUT: Duration = Duration::from_secs(60);
let mut child = Command::new(pounce_exe())
.arg("--problem")
.arg("bounded-quadratic")
.arg("--minima")
.arg("mlsl")
.arg("--n-minima")
.arg("6")
.arg("--max-solves")
.arg("20")
.arg("--patience")
.arg("8")
.arg("--samples-per-round")
.arg("20")
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()
.expect("spawn pounce");
let start = Instant::now();
loop {
match child.try_wait().expect("try_wait") {
Some(status) => {
assert!(
status.success(),
"pounce --minima mlsl exited unsuccessfully: {status:?}"
);
return;
}
None => {
if start.elapsed() > TIMEOUT {
let _ = child.kill();
let _ = child.wait();
panic!(
"pounce#103 regression: `--minima mlsl` did not terminate within {}s \
(max-solves 20, patience 8) — the solve-gated loop is spinning again",
TIMEOUT.as_secs()
);
}
thread::sleep(Duration::from_millis(50));
}
}
}
}