1 /// Run sync and async Python scenarios. 2 /// 3 /// The Python scripts are given as identifiers, relative to this 4 /// file. They can be `None` if the sync or async test variant does 5 /// not exist. 6 /// 7 /// The test script can use `import mls_rs_uniffi` to get access to 8 /// the Python bindings. 9 macro_rules! generate_python_tests { 10 ($sync_scenario:ident, None) => { 11 #[cfg(not(mls_build_async))] 12 generate_python_tests!($sync_scenario); 13 }; 14 15 (None, $async_scenario:ident) => { 16 #[cfg(mls_build_async)] 17 generate_python_tests!($async_scenario); 18 }; 19 20 ($sync_scenario:ident, $async_scenario:ident) => { 21 #[cfg(not(mls_build_async))] 22 generate_python_tests!($sync_scenario); 23 24 #[cfg(mls_build_async)] 25 generate_python_tests!($async_scenario); 26 }; 27 28 ($scenario:ident) => { 29 #[test] 30 fn $scenario() -> Result<(), Box<dyn std::error::Error>> { 31 let target_dir = env!("CARGO_TARGET_TMPDIR"); 32 let script_path = format!("tests/{}.py", stringify!($scenario)); 33 uniffi_bindgen::bindings::python::run_script( 34 &target_dir, 35 "mls-rs-uniffi", 36 &script_path, 37 vec![], 38 &uniffi_bindgen::bindings::RunScriptOptions::default(), 39 ) 40 .map_err(Into::into) 41 } 42 }; 43 } 44 45 generate_python_tests!( 46 generate_signature_keypair_sync, 47 generate_signature_keypair_async 48 ); 49 generate_python_tests!(client_config_default_sync, client_config_default_async); 50 generate_python_tests!(custom_storage_sync, None); 51 generate_python_tests!(simple_scenario_sync, simple_scenario_async); 52 generate_python_tests!(ratchet_tree_sync, ratchet_tree_async); 53 generate_python_tests!(roster_update_sync, None); 54