Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/forge/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ impl TestOutcome {
successes.to_string().green()
)?;

// Show helpful hint for rerunning failed tests
let test_word = if failures == 1 { "test" } else { "tests" };
sh_println!(
"\nTip: Run {} to retry only the {} failed {}",
"`forge test --rerun`".cyan(),
failures,
test_word
)?;

// TODO: Avoid process::exit
std::process::exit(1);
}
Expand Down
6 changes: 6 additions & 0 deletions crates/forge/tests/cli/eip712.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ Encountered 1 failing test in test/Structs.sol:DummyTest

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]]);
});

Expand Down Expand Up @@ -394,6 +396,8 @@ Encountered 1 failing test in src/Eip712Cheat.sol:Eip712Test

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]]);

cmd.forge_fuse().args(["bind-json"]).assert_success();
Expand Down Expand Up @@ -438,6 +442,8 @@ Encountered 1 failing test in src/Eip712Cheat.sol:Eip712Test

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]]);

cmd.forge_fuse().args(["bind-json", "utils/CustomJsonBindings.sol"]).assert_success();
Expand Down
2 changes: 2 additions & 0 deletions crates/forge/tests/cli/failure_assertions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Encountered 2 failing tests in src/DeprecationTestFail.t.sol:DeprecationTestFail

Encountered a total of 2 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 2 failed tests

"#]]);
});

Expand Down
4 changes: 4 additions & 0 deletions crates/forge/tests/cli/inline_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ Encountered 1 failing test in test/inline.sol:Inline

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]]);
});

Expand Down Expand Up @@ -192,6 +194,8 @@ Encountered 1 failing test in test/inline.sol:Inline

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]]);
});

Expand Down
24 changes: 24 additions & 0 deletions crates/forge/tests/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ Encountered 1 failing test in test/Contract.t.sol:CustomTypesTest

Encountered a total of 1 failing tests, 1 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]]);
});

Expand Down Expand Up @@ -763,6 +765,8 @@ Encountered 1 failing test in test/CounterFuzz.t.sol:CounterTest

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]]);
});

Expand Down Expand Up @@ -813,6 +817,8 @@ Encountered 1 failing test in test/CounterInvariant.t.sol:CounterTest

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]]);
});

Expand Down Expand Up @@ -864,6 +870,8 @@ Encountered 2 failing tests in test/ReplayFailures.t.sol:ReplayFailuresTest

Encountered a total of 2 failing tests, 2 tests succeeded

Tip: Run `forge test --rerun` to retry only the 2 failed tests

"#]]);

// Test failure filter should be persisted.
Expand All @@ -887,6 +895,8 @@ Encountered 2 failing tests in test/ReplayFailures.t.sol:ReplayFailuresTest

Encountered a total of 2 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 2 failed tests

"#]]);
});

Expand Down Expand Up @@ -2871,6 +2881,8 @@ Encountered 1 failing test in test/Foo.t.sol:ContractTest

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]]);
});

Expand Down Expand Up @@ -3001,6 +3013,8 @@ Encountered 1 failing test in test/SuppressTracesTest.t.sol:SuppressTracesTest

Encountered a total of 1 failing tests, 1 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]],
);

Expand Down Expand Up @@ -3063,6 +3077,8 @@ Encountered 1 failing test in test/SuppressTracesTest.t.sol:SuppressTracesTest

Encountered a total of 1 failing tests, 1 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]]);
});

Expand Down Expand Up @@ -3747,6 +3763,8 @@ Encountered 1 failing test in test/Counter.t.sol:CounterTest

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]]);
});

Expand Down Expand Up @@ -3855,6 +3873,8 @@ Encountered 3 failing tests in test/NonContractCallRevertTest.t.sol:NonContractC

Encountered a total of 3 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 3 failed tests

"#]]);
});

Expand Down Expand Up @@ -3937,6 +3957,8 @@ Encountered 1 failing test in test/NonContractDelegateCallRevertTest.t.sol:NonCo

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]]);
});

Expand Down Expand Up @@ -4128,5 +4150,7 @@ Encountered 2 failing tests in test/Counter.t.sol:CounterTest

Encountered a total of 2 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 2 failed tests

"#]]);
});
6 changes: 6 additions & 0 deletions crates/forge/tests/it/invariant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,8 @@ Encountered 1 failing test in test/InvariantSequenceLenTest.t.sol:InvariantSeque

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]],
);

Expand All @@ -1137,6 +1139,8 @@ Encountered 1 failing test in test/InvariantSequenceLenTest.t.sol:InvariantSeque

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]],
);

Expand All @@ -1158,6 +1162,8 @@ Encountered 1 failing test in test/InvariantSequenceLenTest.t.sol:InvariantSeque

Encountered a total of 1 failing tests, 0 tests succeeded

Tip: Run `forge test --rerun` to retry only the 1 failed test

"#]],
);
});
Expand Down
2 changes: 2 additions & 0 deletions crates/forge/tests/it/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ Encountered 6 failing tests in test/CounterTable.t.sol:CounterTableTest

Encountered a total of 6 failing tests, 2 tests succeeded

Tip: Run `forge test --rerun` to retry only the 6 failed tests

"#]]);
});

Expand Down
Loading