@@ -43,6 +43,7 @@ use std::{
4343 sync:: Arc ,
4444 time:: Instant ,
4545} ;
46+ use tokio:: signal;
4647use tracing:: Span ;
4748
4849/// When running tests, we deploy all external libraries present in the project. To avoid additional
@@ -395,14 +396,22 @@ impl<'a> ContractRunner<'a> {
395396 return SuiteResult :: new ( start. elapsed ( ) , test_results, warnings) ;
396397 }
397398
398- let fail_fast = & self . tcfg . fail_fast ;
399+ let early_exit = & self . tcfg . early_exit ;
400+
401+ if self . progress . is_some ( ) {
402+ let interrupt = early_exit. clone ( ) ;
403+ self . tokio_handle . spawn ( async move {
404+ signal:: ctrl_c ( ) . await . expect ( "Failed to listen for Ctrl+C" ) ;
405+ interrupt. record_exit ( ) ;
406+ } ) ;
407+ }
399408
400409 let test_results = functions
401410 . par_iter ( )
402- . map ( |& func| {
411+ . filter_map ( |& func| {
403412 // Early exit if we're running with fail-fast and a test already failed.
404- if fail_fast . should_stop ( ) {
405- return ( func . signature ( ) , TestResult :: setup_result ( setup . clone ( ) ) ) ;
413+ if early_exit . should_stop ( ) {
414+ return None ;
406415 }
407416
408417 let start = Instant :: now ( ) ;
@@ -435,10 +444,10 @@ impl<'a> ContractRunner<'a> {
435444
436445 // Set fail fast flag if current test failed.
437446 if res. status . is_failure ( ) {
438- fail_fast . record_fail ( ) ;
447+ early_exit . record_exit ( ) ;
439448 }
440449
441- ( sig, res)
450+ Some ( ( sig, res) )
442451 } )
443452 . collect :: < BTreeMap < _ , _ > > ( ) ;
444453
@@ -637,7 +646,7 @@ impl<'a> FunctionRunner<'a> {
637646 let mut result = FuzzTestResult :: default ( ) ;
638647
639648 for i in 0 ..fixtures_len {
640- if self . tcfg . fail_fast . should_stop ( ) {
649+ if self . tcfg . early_exit . should_stop ( ) {
641650 return self . result ;
642651 }
643652
@@ -822,7 +831,7 @@ impl<'a> FunctionRunner<'a> {
822831 & self . setup . fuzz_fixtures ,
823832 & self . setup . deployed_libs ,
824833 progress. as_ref ( ) ,
825- & self . tcfg . fail_fast ,
834+ & self . tcfg . early_exit ,
826835 ) {
827836 Ok ( x) => x,
828837 Err ( e) => {
@@ -856,6 +865,7 @@ impl<'a> FunctionRunner<'a> {
856865 & mut self . result . deprecated_cheatcodes ,
857866 progress. as_ref ( ) ,
858867 show_solidity,
868+ & self . tcfg . early_exit ,
859869 ) {
860870 Ok ( call_sequence) => {
861871 if !call_sequence. is_empty ( ) {
@@ -973,7 +983,7 @@ impl<'a> FunctionRunner<'a> {
973983 self . address ,
974984 & self . cr . mcr . revert_decoder ,
975985 progress. as_ref ( ) ,
976- & self . tcfg . fail_fast ,
986+ & self . tcfg . early_exit ,
977987 ) {
978988 Ok ( x) => x,
979989 Err ( e) => {
0 commit comments