use std::process::Command;
fn synth() -> &'static str {
env!("CARGO_BIN_EXE_synth")
}
fn fixture(name: &str) -> std::path::PathBuf {
std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../..")
.join("scripts/repro")
.join(name)
}
fn compile(wat: &str, out: &str, extra_env: &[(&str, &str)]) -> std::process::Output {
let mut cmd = Command::new(synth());
for (k, v) in extra_env {
cmd.env(k, v);
}
cmd.args([
"compile",
fixture(wat).to_str().unwrap(),
"-o",
out,
"-b",
"arm",
"--target",
"cortex-m4",
"--relocatable",
"--all-exports",
])
.output()
.expect("failed to run synth")
}
#[test]
fn i64_stack_param_shapes_compile_without_skips_503() {
let out = compile("i64_stack_param_503.wat", "/tmp/cli_503.o", &[]);
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(out.status.success(), "compile failed:\n{stderr}");
assert!(
!stderr.contains("skipping function"),
"an i64-stack-param shape was skipped (the #503-i64 class regressed):\n{stderr}"
);
}
#[test]
fn i64_spill_pool_exhaustion_rescued_by_pool_grow_587() {
let out = compile(
"i64_spill_pool_587.wat",
"/tmp/cli_587.o",
&[("SYNTH_RECOVERY_STATS", "1")],
);
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(out.status.success(), "compile failed:\n{stderr}");
assert!(
!stderr.contains("skipping function"),
"the i64-dense function was skipped (the #587 pool-grow rung regressed):\n{stderr}"
);
assert!(
stderr.contains("rung=pool-grow result=ok"),
"expected the pool-grow rung to produce the result (recovery stats):\n{stderr}"
);
}