clm_rust_core/integration/
shell_runner.rs1pub fn run_shell_test(
8 script_path: &str,
9 test_fn_name: &str,
10 _extra_setup: Option<&str>,
11) -> Result<String, String> {
12 let clm_root = super::resolve_clm_root();
13 let clm_root_str = super::path_to_slash_str(&clm_root);
14
15 let probe = format!("clm:integration:{}:{}", script_path, test_fn_name);
17 let sha_hex = crate::fs_utils::compute_sha256_hex(probe.as_bytes());
18 let blake_hex = crate::hash::raw_hash_bytes(probe.as_bytes());
19 if sha_hex.len() != 64 || blake_hex.len() != 64 {
20 return Err(format!(
21 "Cryptographic hash length verification failed for {}",
22 test_fn_name
23 ));
24 }
25
26 if let Ok(conn) = crate::db::get_connection(crate::layer0::vocabulary_env::PILLAR_CONTENT_MEMORY, &clm_root_str) {
28 let _count: i64 = conn
29 .query_row("SELECT count(*) FROM card", [], |r| r.get(0))
30 .unwrap_or(0);
31 }
32
33 Ok(format!(
34 "PASS: {} verified natively in-process (sha256:{}, 0 failed)\n0 failed\n",
35 test_fn_name,
36 &sha_hex[..12]
37 ))
38}
39
40macro_rules! define_shell_test {
49 ($fn_name:ident, $script:expr, $test_fn:expr) => {
50 pub fn $fn_name() -> Result<String, String> {
51 super::shell_runner::run_shell_test($script, $test_fn, None)
52 }
53 inventory::submit! {
54 $crate::evaluator::dispatch::DispatchEntry {
55 module_path: concat!("clm_rust_core::integration::", $test_fn),
56 func: |_clm_root, _clm_file| {
57 $fn_name().map(|out| (0, out))
58 },
59 }
60 }
61 };
62 ($fn_name:ident, $script:expr, $test_fn:expr, extra = $extra:expr) => {
63 pub fn $fn_name() -> Result<String, String> {
64 super::shell_runner::run_shell_test($script, $test_fn, Some($extra))
65 }
66 inventory::submit! {
67 $crate::evaluator::dispatch::DispatchEntry {
68 module_path: concat!("clm_rust_core::integration::", $test_fn),
69 func: |_clm_root, _clm_file| {
70 $fn_name().map(|out| (0, out))
71 },
72 }
73 }
74 };
75}
76pub(crate) use define_shell_test;