-
Notifications
You must be signed in to change notification settings - Fork 239
Don't fetch block numbers nor check rpc version for ignored tests #3742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 8 commits
824de94
5fd44ff
bb4e267
8546e3e
d09df8f
dee6faf
c0eeffb
5b466f8
a6cba94
11463a7
a6d2fdc
0da75a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,15 +1,20 @@ | ||||||||||||||||||||||||||
use super::maat::env_ignore_fork_tests; | ||||||||||||||||||||||||||
use crate::{block_number_map::BlockNumberMap, scarb::config::ForkTarget}; | ||||||||||||||||||||||||||
use crate::{ | ||||||||||||||||||||||||||
block_number_map::BlockNumberMap, scarb::config::ForkTarget, test_filter::TestsFilter, | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
use anyhow::{Result, anyhow}; | ||||||||||||||||||||||||||
use cheatnet::runtime_extensions::forge_config_extension::config::{ | ||||||||||||||||||||||||||
BlockId, InlineForkConfig, OverriddenForkConfig, RawForkConfig, | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
use conversions::byte_array::ByteArray; | ||||||||||||||||||||||||||
use forge_runner::package_tests::{ | ||||||||||||||||||||||||||
with_config::TestTargetWithConfig, | ||||||||||||||||||||||||||
with_config_resolved::{ | ||||||||||||||||||||||||||
ResolvedForkConfig, TestCaseResolvedConfig, TestCaseWithResolvedConfig, | ||||||||||||||||||||||||||
TestTargetWithResolvedConfig, | ||||||||||||||||||||||||||
use forge_runner::{ | ||||||||||||||||||||||||||
TestCaseFilter, | ||||||||||||||||||||||||||
package_tests::{ | ||||||||||||||||||||||||||
with_config::TestTargetWithConfig, | ||||||||||||||||||||||||||
with_config_resolved::{ | ||||||||||||||||||||||||||
ResolvedForkConfig, TestCaseResolvedConfig, TestCaseWithResolvedConfig, | ||||||||||||||||||||||||||
TestTargetWithResolvedConfig, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
use starknet_api::block::BlockNumber; | ||||||||||||||||||||||||||
|
@@ -19,28 +24,30 @@ pub async fn resolve_config( | |||||||||||||||||||||||||
test_target: TestTargetWithConfig, | ||||||||||||||||||||||||||
fork_targets: &[ForkTarget], | ||||||||||||||||||||||||||
block_number_map: &mut BlockNumberMap, | ||||||||||||||||||||||||||
tests_filter: &TestsFilter, | ||||||||||||||||||||||||||
) -> Result<TestTargetWithResolvedConfig> { | ||||||||||||||||||||||||||
let mut test_cases = Vec::with_capacity(test_target.test_cases.len()); | ||||||||||||||||||||||||||
let env_ignore_fork_tests = env_ignore_fork_tests(); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
for case in test_target.test_cases { | ||||||||||||||||||||||||||
let ignored = | ||||||||||||||||||||||||||
case.config.ignored || (env_ignore_fork_tests && case.config.fork_config.is_some()); | ||||||||||||||||||||||||||
test_cases.push(TestCaseWithResolvedConfig { | ||||||||||||||||||||||||||
name: case.name, | ||||||||||||||||||||||||||
test_details: case.test_details, | ||||||||||||||||||||||||||
config: TestCaseResolvedConfig { | ||||||||||||||||||||||||||
available_gas: case.config.available_gas, | ||||||||||||||||||||||||||
ignored: case.config.ignored | ||||||||||||||||||||||||||
|| (env_ignore_fork_tests && case.config.fork_config.is_some()), | ||||||||||||||||||||||||||
ignored, | ||||||||||||||||||||||||||
fork_config: if ignored && tests_filter.should_be_run(&case) { | ||||||||||||||||||||||||||
None | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
resolve_fork_config(case.config.fork_config, block_number_map, fork_targets) | ||||||||||||||||||||||||||
.await? | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
|
fork_config: if ignored && tests_filter.should_be_run(&case) { | |
None | |
} else { | |
resolve_fork_config(case.config.fork_config, block_number_map, fork_targets) | |
.await? | |
}, | |
fork_config: tests_filter.should_be_run(&case) { | |
resolve_fork_config(case.config.fork_config, block_number_map, fork_targets) | |
.await? | |
} else { | |
None | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flipped, thanks for mentioning, this sounds more intuitive actually.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
use crate::shared_cache::FailedTestsCache; | ||
use anyhow::Result; | ||
use forge_runner::TestCaseFilter; | ||
use forge_runner::package_tests::TestCase; | ||
use forge_runner::package_tests::with_config_resolved::TestCaseWithResolvedConfig; | ||
use forge_runner::{TestCaseFilter, TestCaseIsIgnored}; | ||
|
||
#[derive(Debug, PartialEq)] | ||
// Specifies what tests should be included | ||
|
@@ -26,7 +27,7 @@ pub(crate) enum NameFilter { | |
} | ||
|
||
#[derive(Debug, PartialEq)] | ||
pub(crate) enum IgnoredFilter { | ||
pub enum IgnoredFilter { | ||
NotIgnored, | ||
Ignored, | ||
All, | ||
|
@@ -117,9 +118,24 @@ impl TestsFilter { | |
} | ||
} | ||
|
||
impl Default for TestsFilter { | ||
fn default() -> Self { | ||
Self { | ||
name_filter: NameFilter::All, | ||
ignored_filter: IgnoredFilter::All, | ||
last_failed_filter: false, | ||
skip_filter: Vec::new(), | ||
failed_tests_cache: FailedTestsCache::default(), | ||
} | ||
} | ||
} | ||
|
||
|
||
impl TestCaseFilter for TestsFilter { | ||
fn should_be_run(&self, test_case: &TestCaseWithResolvedConfig) -> bool { | ||
let ignored = test_case.config.ignored; | ||
fn should_be_run<T>(&self, test_case: &TestCase<T>) -> bool | ||
where | ||
T: TestCaseIsIgnored, | ||
{ | ||
let ignored = test_case.config.is_ignored(); | ||
|
||
match self.ignored_filter { | ||
IgnoredFilter::All => true, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be inlined again