Skip to content

Commit 0f628e5

Browse files
authored
Add tests for --trace-components flag (#3605)
commit-id:0a3ba8ce --- **Stack**: - #3612 - #3609 - #3605⚠️ *Part of a stack created by [spr](https://github.com/ejoffe/spr). Do not merge manually using the UI - doing so may have unexpected results.*
1 parent 8a8e4ed commit 0f628e5

File tree

1 file changed

+66
-1
lines changed

1 file changed

+66
-1
lines changed

crates/forge/tests/e2e/debugging.rs

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
use super::common::runner::{setup_package, test_runner};
2-
use indoc::formatdoc;
2+
use indoc::{formatdoc, indoc};
33
use shared::test_utils::output_assert::assert_stdout_contains;
44

5+
#[test]
6+
fn debugging_trace_custom_components() {
7+
let temp = setup_package("debugging");
8+
9+
let output = test_runner(&temp)
10+
.arg("--trace-components")
11+
.arg("contract-name")
12+
.arg("call-result")
13+
.arg("call-type")
14+
.assert()
15+
.code(1);
16+
17+
assert_stdout_contains(output, test_output(custom_output_trace_message));
18+
}
19+
520
#[test]
621
fn debugging_trace_detailed() {
722
let temp = setup_package("debugging");
@@ -80,6 +95,26 @@ fn debugging_trace_minimal_fork() {
8095
assert_stdout_contains(output, test_output(minimal_debugging_trace_message_fork));
8196
}
8297

98+
#[test]
99+
fn debugging_double_flags() {
100+
let temp = setup_package("debugging");
101+
102+
test_runner(&temp)
103+
.arg("--trace-verbosity")
104+
.arg("minimal")
105+
.arg("--trace-components")
106+
.arg("contract-name")
107+
.assert()
108+
.code(2)
109+
.stderr_eq(indoc! {"
110+
error: the argument '--trace-verbosity <TRACE_VERBOSITY>' cannot be used with '--trace-components <TRACE_COMPONENTS>...'
111+
112+
Usage: snforge test --trace-verbosity <TRACE_VERBOSITY> [TEST_FILTER] [-- <ADDITIONAL_ARGS>...]
113+
114+
For more information, try '--help'.
115+
"});
116+
}
117+
83118
fn test_output(trace_message_fn: fn(&str) -> String) -> String {
84119
formatdoc! {r"
85120
[..]Compiling[..]
@@ -311,3 +346,33 @@ fn minimal_debugging_trace_message_fork(test_name: &str) -> String {
311346
└─ [contract name] forked contract
312347
"}
313348
}
349+
350+
fn custom_output_trace_message(test_name: &str) -> String {
351+
formatdoc! {r"
352+
[test name] trace_info_integrationtest::test_trace::test_debugging_trace_{test_name}
353+
├─ [selector] execute_calls
354+
│ ├─ [contract name] SimpleContract
355+
│ ├─ [call type] Call
356+
│ ├─ [call result] success: array![RecursiveCall {{ contract_address: ContractAddress([..]), payload: array![RecursiveCall {{ contract_address: ContractAddress([..]), payload: array![] }}, RecursiveCall {{ contract_address: ContractAddress([..]), payload: array![] }}] }}, RecursiveCall {{ contract_address: ContractAddress([..]), payload: array![] }}]
357+
│ ├─ [selector] execute_calls
358+
│ │ ├─ [contract name] SimpleContract
359+
│ │ ├─ [call type] Call
360+
│ │ ├─ [call result] success: array![RecursiveCall {{ contract_address: ContractAddress([..]), payload: array![] }}, RecursiveCall {{ contract_address: ContractAddress([..]), payload: array![] }}]
361+
│ │ ├─ [selector] execute_calls
362+
│ │ │ ├─ [contract name] SimpleContract
363+
│ │ │ ├─ [call type] Call
364+
│ │ │ └─ [call result] success: array![]
365+
│ │ └─ [selector] execute_calls
366+
│ │ ├─ [contract name] SimpleContract
367+
│ │ ├─ [call type] Call
368+
│ │ └─ [call result] success: array![]
369+
│ └─ [selector] execute_calls
370+
│ ├─ [contract name] SimpleContract
371+
│ ├─ [call type] Call
372+
│ └─ [call result] success: array![]
373+
└─ [selector] fail
374+
├─ [contract name] SimpleContract
375+
├─ [call type] Call
376+
└─ [call result] panic: (0x1, 0x2, 0x3, 0x4, 0x5)
377+
"}
378+
}

0 commit comments

Comments
 (0)