@@ -41,7 +41,7 @@ use foundry_config::{
4141use foundry_debugger:: Debugger ;
4242use foundry_evm:: {
4343 opts:: EvmOpts ,
44- traces:: { backtrace:: BacktraceBuilder , identifier:: TraceIdentifiers } ,
44+ traces:: { backtrace:: BacktraceBuilder , identifier:: TraceIdentifiers , prune_trace_depth } ,
4545} ;
4646use regex:: Regex ;
4747use std:: {
@@ -136,6 +136,10 @@ pub struct TestArgs {
136136 #[ arg( long, short, env = "FORGE_SUPPRESS_SUCCESSFUL_TRACES" , help_heading = "Display options" ) ]
137137 suppress_successful_traces : bool ,
138138
139+ /// Defines the depth of a trace
140+ #[ arg( long, short) ]
141+ depth : Option < usize > ,
142+
139143 /// Output test results as JUnit XML report.
140144 #[ arg( long, conflicts_with_all = [ "quiet" , "json" , "gas_report" , "summary" , "list" , "show_progress" ] , help_heading = "Display options" ) ]
141145 pub junit : bool ,
@@ -652,6 +656,11 @@ impl TestArgs {
652656
653657 if should_include {
654658 decode_trace_arena ( arena, & decoder) . await ;
659+
660+ if let Some ( depth) = self . depth {
661+ prune_trace_depth ( arena, depth) ;
662+ }
663+
655664 decoded_traces. push ( render_trace_arena_inner ( arena, false , verbosity > 4 ) ) ;
656665 }
657666 }
@@ -1037,6 +1046,12 @@ mod tests {
10371046 assert ! ( args. fuzz_seed. is_some( ) ) ;
10381047 }
10391048
1049+ #[ test]
1050+ fn depth_trace ( ) {
1051+ let args: TestArgs = TestArgs :: parse_from ( [ "foundry-cli" , "--depth" , "2" ] ) ;
1052+ assert ! ( args. depth. is_some( ) ) ;
1053+ }
1054+
10401055 // <https://github.com/foundry-rs/foundry/issues/5913>
10411056 #[ test]
10421057 fn fuzz_seed_exists ( ) {
0 commit comments