use std::path::PathBuf;
use std::process::Command;
fn pounce_exe() -> PathBuf {
PathBuf::from(env!("CARGO_BIN_EXE_pounce"))
}
fn fixture_nl() -> PathBuf {
let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
p.push("tests");
p.push("fixtures");
p.push("parametric.nl");
p
}
#[test]
fn l1_fallback_flag_does_not_panic_in_cli() {
let output = Command::new(pounce_exe())
.arg(fixture_nl())
.arg("l1_fallback_on_restoration_failure=yes")
.output()
.expect("spawn pounce");
let code = output.status.code();
assert!(
matches!(code, Some(0) | Some(1)),
"unexpected exit: {:?} stderr={}",
output.status,
String::from_utf8_lossy(&output.stderr),
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
!stderr.contains("restoration factory invoked more than once"),
"panic message in stderr (pounce#24 regression):\n{stderr}",
);
}
#[test]
fn l1_exact_penalty_barrier_flag_does_not_panic_in_cli() {
let output = Command::new(pounce_exe())
.arg(fixture_nl())
.arg("l1_exact_penalty_barrier=yes")
.output()
.expect("spawn pounce");
let code = output.status.code();
assert!(
matches!(code, Some(0) | Some(1)),
"unexpected exit: {:?} stderr={}",
output.status,
String::from_utf8_lossy(&output.stderr),
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
!stderr.contains("restoration factory invoked more than once"),
"panic message in stderr (pounce#24 regression):\n{stderr}",
);
}
#[test]
fn l1_fallback_with_infeasible_problem_drives_second_inner_solve() {
let output = Command::new(pounce_exe())
.args(["--problem", "infeasible-eq"])
.arg("l1_fallback_on_restoration_failure=yes")
.output()
.expect("spawn pounce");
let code = output.status.code();
let stderr = String::from_utf8_lossy(&output.stderr);
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
!stderr.contains("restoration factory invoked more than once"),
"panic message in stderr (pounce#24 regression):\n{stderr}",
);
assert!(
matches!(code, Some(0) | Some(1)),
"unexpected exit: {:?} stderr={stderr}",
output.status,
);
assert!(
stdout.lines().any(|l| l.contains('r')
&& l.split_whitespace()
.next()
.is_some_and(|t| t.ends_with('r'))),
"expected a restoration iteration in stdout, fixture did not \
exercise the multi-pass path:\n{stdout}",
);
}
#[test]
fn l1_exact_penalty_barrier_with_infeasible_problem() {
let output = Command::new(pounce_exe())
.args(["--problem", "infeasible-eq"])
.arg("l1_exact_penalty_barrier=yes")
.output()
.expect("spawn pounce");
let code = output.status.code();
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
!stderr.contains("restoration factory invoked more than once"),
"panic message in stderr (pounce#24 regression):\n{stderr}",
);
assert!(
matches!(code, Some(0) | Some(1)),
"unexpected exit: {:?} stderr={stderr}",
output.status,
);
}