22use crate :: {
33 cmd:: {
44 forge:: { build:: CoreBuildArgs , install, test:: FilterArgs } ,
5- Cmd , LoadConfig ,
5+ LoadConfig ,
66 } ,
77 utils:: { p_println, STATIC_FUZZ_SEED } ,
88} ;
@@ -31,7 +31,7 @@ use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs};
3131use foundry_config:: Config ;
3232use foundry_evm:: utils:: evm_spec;
3333use semver:: Version ;
34- use std:: { collections:: HashMap , sync:: mpsc:: channel, thread } ;
34+ use std:: { collections:: HashMap , sync:: mpsc:: channel} ;
3535use tracing:: trace;
3636
3737// Loads project's figment and merges the build cli arguments into it
@@ -61,12 +61,8 @@ impl CoverageArgs {
6161 pub fn build_args ( & self ) -> & CoreBuildArgs {
6262 & self . opts
6363 }
64- }
65-
66- impl Cmd for CoverageArgs {
67- type Output = ( ) ;
6864
69- fn run ( self ) -> eyre:: Result < Self :: Output > {
65+ pub async fn run ( self ) -> eyre:: Result < ( ) > {
7066 let ( mut config, evm_opts) = self . load_config_and_evm_opts_emit_warnings ( ) ?;
7167
7268 // install missing dependencies
@@ -85,7 +81,7 @@ impl Cmd for CoverageArgs {
8581 let report = self . prepare ( & config, output. clone ( ) ) ?;
8682
8783 p_println ! ( !self . opts. silent => "Running tests..." ) ;
88- self . collect ( project, output, report, config, evm_opts)
84+ self . collect ( project, output, report, config, evm_opts) . await
8985 }
9086}
9187
@@ -255,7 +251,7 @@ impl CoverageArgs {
255251 }
256252
257253 /// Runs tests, collects coverage data and generates the final report.
258- fn collect (
254+ async fn collect (
259255 self ,
260256 project : Project ,
261257 output : ProjectCompileOutput ,
@@ -267,7 +263,7 @@ impl CoverageArgs {
267263
268264 // Build the contract runner
269265 let evm_spec = evm_spec ( & config. evm_version ) ;
270- let env = evm_opts. evm_env_blocking ( ) ? ;
266+ let env = evm_opts. evm_env ( ) . await ;
271267 let mut runner = MultiContractRunnerBuilder :: default ( )
272268 . initial_balance ( evm_opts. initial_balance )
273269 . evm_spec ( evm_spec)
@@ -280,8 +276,12 @@ impl CoverageArgs {
280276
281277 // Run tests
282278 let known_contracts = runner. known_contracts . clone ( ) ;
279+ let filter = self . filter ;
283280 let ( tx, rx) = channel :: < ( String , SuiteResult ) > ( ) ;
284- let handle = thread:: spawn ( move || runner. test ( & self . filter , Some ( tx) , Default :: default ( ) ) ) ;
281+ let handle =
282+ tokio:: task:: spawn (
283+ async move { runner. test ( filter, Some ( tx) , Default :: default ( ) ) . await } ,
284+ ) ;
285285
286286 // Add hit data to the coverage report
287287 for ( artifact_id, hits) in rx
@@ -313,7 +313,7 @@ impl CoverageArgs {
313313 }
314314
315315 // Reattach the thread
316- let _ = handle. join ( ) ;
316+ let _ = handle. await ;
317317
318318 // Output final report
319319 for report_kind in self . report {
0 commit comments