fix(derive): require generated handler symbols

Make #[slhx::handler] fail when slhx.syms is missing instead of silently skipping generated handle checks. Add compile-fail coverage with an actionable build.rs hint.

req: build/003

req: test/003
This commit is contained in:
slhx agent
2026-05-25 21:26:48 +02:00
parent dca26511cc
commit 87a19fd923
2 changed files with 99 additions and 33 deletions
+51
View File
@@ -60,6 +60,57 @@ fn known() {}
);
}
#[test]
fn handler_macro_reports_missing_syms() {
// req: build/003 req: test/003
let fixture = Fixture::new("slhx-derive-handler-syms-fail");
fixture.write(
"Cargo.toml",
&format!(
r#"[package]
name = "slhx-derive-handler-syms-fail"
version = "0.0.0"
edition = "2021"
[lib]
path = "src/lib.rs"
[dependencies]
slhx = {{ path = {:?} }}
"#,
repo_path("slhx")
),
);
fixture.write(
"build.rs",
r#"fn main() {
println!("cargo:rerun-if-changed=build.rs");
}
"#,
);
fixture.write(
"src/lib.rs",
r#"#[slhx::handler]
fn create() -> impl slhx::IntoEffect {
slhx::EffectBatch::default()
}
"#,
);
let output = check_fixture(&fixture);
assert!(!output.status.success(), "fixture unexpectedly compiled");
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("#[slhx::handler] could not find"),
"missing handler syms diagnostic in stderr:\n{stderr}"
);
assert!(
stderr.contains("add slhx_build::app().run()? to build.rs"),
"missing build.rs hint in stderr:\n{stderr}"
);
}
#[test]
fn form_handle_requires_form_parameter() {
// req: form/004 req: form/006 req: test/003