mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-02 13:23:10 +00:00
fix: test suite proc macro
This commit is contained in:
parent
37360e6d8c
commit
31783d9b78
@ -10,7 +10,8 @@ members = [
|
||||
"wallet",
|
||||
"sequencer_core",
|
||||
"common",
|
||||
"nssa",
|
||||
"nssa",
|
||||
"proc_macro_test_attribute",
|
||||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
|
||||
@ -17,6 +17,8 @@ borsh.workspace = true
|
||||
|
||||
nssa-core = { path = "../nssa/core", features = ["host"] }
|
||||
|
||||
proc_macro_test_attribute = { path = "../proc_macro_test_attribute" }
|
||||
|
||||
[dependencies.clap]
|
||||
features = ["derive", "env"]
|
||||
workspace = true
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1573
integration_tests/src/test_suite_map.rs
Normal file
1573
integration_tests/src/test_suite_map.rs
Normal file
File diff suppressed because it is too large
Load Diff
9
proc_macro_test_attribute/Cargo.toml
Normal file
9
proc_macro_test_attribute/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "proc_macro_test_attribute"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
49
proc_macro_test_attribute/src/lib.rs
Normal file
49
proc_macro_test_attribute/src/lib.rs
Normal file
@ -0,0 +1,49 @@
|
||||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::*;
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn test_suite_fn(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
let input = item.to_string();
|
||||
|
||||
let fn_keyword = "fn ";
|
||||
let fn_keyword_alternative = "fn\n";
|
||||
|
||||
let mut start_opt = None;
|
||||
let mut fn_name = String::new();
|
||||
|
||||
if let Some(start) = input.find(fn_keyword) {
|
||||
start_opt = Some(start);
|
||||
} else if let Some(start) = input.find(fn_keyword_alternative) {
|
||||
start_opt = Some(start);
|
||||
}
|
||||
|
||||
if let Some(start) = start_opt {
|
||||
let rest = &input[start + fn_keyword.len()..];
|
||||
if let Some(end) = rest.find(|c: char| c == '(' || c.is_whitespace()) {
|
||||
let name = &rest[..end];
|
||||
fn_name = name.to_string();
|
||||
}
|
||||
} else {
|
||||
println!("ERROR: keyword fn not found");
|
||||
}
|
||||
|
||||
let extension = format!(
|
||||
r#"
|
||||
{input}
|
||||
|
||||
function_map.insert("{fn_name}".to_string(), |home_dir: PathBuf| Box::pin(async {{
|
||||
let res = pre_test(home_dir).await.unwrap();
|
||||
|
||||
info!("Waiting for first block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
{fn_name}().await;
|
||||
|
||||
post_test(res).await;
|
||||
}}));
|
||||
"#
|
||||
);
|
||||
|
||||
extension.parse().unwrap()
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user