|
1 | 1 | use super::common::runner::{setup_package, test_runner};
|
2 |
| -use indoc::formatdoc; |
| 2 | +use indoc::{formatdoc, indoc}; |
3 | 3 | use shared::test_utils::output_assert::assert_stdout_contains;
|
4 | 4 |
|
| 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 | + |
5 | 20 | #[test]
|
6 | 21 | fn debugging_trace_detailed() {
|
7 | 22 | let temp = setup_package("debugging");
|
@@ -80,6 +95,26 @@ fn debugging_trace_minimal_fork() {
|
80 | 95 | assert_stdout_contains(output, test_output(minimal_debugging_trace_message_fork));
|
81 | 96 | }
|
82 | 97 |
|
| 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 | + |
83 | 118 | fn test_output(trace_message_fn: fn(&str) -> String) -> String {
|
84 | 119 | formatdoc! {r"
|
85 | 120 | [..]Compiling[..]
|
@@ -311,3 +346,33 @@ fn minimal_debugging_trace_message_fork(test_name: &str) -> String {
|
311 | 346 | └─ [contract name] forked contract
|
312 | 347 | "}
|
313 | 348 | }
|
| 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