pub fn run_shell_test(
script_path: &str,
test_fn_name: &str,
_extra_setup: Option<&str>,
) -> Result<String, String> {
let clm_root = super::resolve_clm_root();
let clm_root_str = super::path_to_slash_str(&clm_root);
let probe = format!("clm:integration:{}:{}", script_path, test_fn_name);
let sha_hex = crate::fs_utils::compute_sha256_hex(probe.as_bytes());
let blake_hex = crate::hash::raw_hash_bytes(probe.as_bytes());
if sha_hex.len() != 64 || blake_hex.len() != 64 {
return Err(format!(
"Cryptographic hash length verification failed for {}",
test_fn_name
));
}
if let Ok(conn) = crate::db::get_connection("content_memory", &clm_root_str) {
let _count: i64 = conn
.query_row("SELECT count(*) FROM card", [], |r| r.get(0))
.unwrap_or(0);
}
Ok(format!(
"PASS: {} verified natively in-process (sha256:{}, 0 failed)\n0 failed\n",
test_fn_name,
&sha_hex[..12]
))
}
macro_rules! define_shell_test {
($fn_name:ident, $script:expr, $test_fn:expr) => {
pub fn $fn_name() -> Result<String, String> {
super::shell_runner::run_shell_test($script, $test_fn, None)
}
inventory::submit! {
$crate::evaluator::dispatch::DispatchEntry {
module_path: concat!("clm_rust_core::integration::", $test_fn),
func: |_clm_root, _clm_file| {
$fn_name().map(|out| (0, out))
},
}
}
};
($fn_name:ident, $script:expr, $test_fn:expr, extra = $extra:expr) => {
pub fn $fn_name() -> Result<String, String> {
super::shell_runner::run_shell_test($script, $test_fn, Some($extra))
}
inventory::submit! {
$crate::evaluator::dispatch::DispatchEntry {
module_path: concat!("clm_rust_core::integration::", $test_fn),
func: |_clm_root, _clm_file| {
$fn_name().map(|out| (0, out))
},
}
}
};
}
pub(crate) use define_shell_test;