Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
refactor(solidity/core/tests-positions-server): filter test functions…
Browse files Browse the repository at this point in the history
… based on foundry naming convention
  • Loading branch information
0xmemorygrinder committed Jan 9, 2024
1 parent 7658542 commit e5eccf4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions toolchains/solidity/core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ serde = { version = "1.0.149", features = ["derive"] }
serde_json = "1.0.89"
tokio = {version = "1.34.0", features = ["full"] }
tower-lsp = "0.20.0"
osmium-libs-solidity-ast-extractor = { path = "../../../../../libs/ast-extractor", version = "0.1.2" }
osmium-libs-solidity-ast-extractor = { path = "../../../../../libs/ast-extractor", version = "0.1.2" }
regex = "1.10.2"
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ impl Backend {

pub fn extract_tests_positions(&self, ast: File) -> Result<GetTestsPositionsResponse> {
let mut res = vec![];
let re = regex::Regex::new(r"^test.*_.+").unwrap();
let contracts = retrieve_contract_nodes(&ast);
for contract in contracts {
let mut tests: Vec<Test> = vec![];
let mut functions = retrieve_functions_nodes(&contract);
let contract_tests = functions.iter_mut().filter(|f| {
f.name.is_some() && f.name.as_ref().unwrap().as_string().starts_with("test")
f.name.is_some() && re.is_match(f.name.as_ref().unwrap().as_string().as_str())
});
for test in contract_tests {
let name = match &test.name {
Expand Down

0 comments on commit e5eccf4

Please sign in to comment.