diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 14fbbf66e5592..42e35a26065ce 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -383,23 +383,14 @@ impl<'a> ContractRunner<'a> { load_contracts(setup.traces.iter().map(|(_, t)| &t.arena), &self.mcr.known_contracts) }); - let test_fail_instances = functions - .iter() - .filter_map(|func| { - TestFunctionKind::classify(&func.name, !func.inputs.is_empty()) - .is_any_test_fail() - .then_some(func.name.clone()) - }) - .collect::>(); - - if !test_fail_instances.is_empty() { - let instances = format!( - "Found {} instances: {}", - test_fail_instances.len(), - test_fail_instances.join(", ") - ); - let fail = TestResult::fail("`testFail*` has been removed. Consider changing to test_Revert[If|When]_Condition and expecting a revert".to_string()); - return SuiteResult::new(start.elapsed(), [(instances, fail)].into(), warnings); + let test_fail_functions = + functions.iter().filter(|func| func.test_function_kind().is_any_test_fail()); + if test_fail_functions.clone().next().is_some() { + let fail = || { + TestResult::fail("`testFail*` has been removed. Consider changing to test_Revert[If|When]_Condition and expecting a revert".to_string()) + }; + let test_results = test_fail_functions.map(|func| (func.signature(), fail())).collect(); + return SuiteResult::new(start.elapsed(), test_results, warnings); } let fail_fast = &self.tcfg.fail_fast; diff --git a/crates/forge/tests/cli/failure_assertions.rs b/crates/forge/tests/cli/failure_assertions.rs index 7032b3a34ba85..d827db79bc819 100644 --- a/crates/forge/tests/cli/failure_assertions.rs +++ b/crates/forge/tests/cli/failure_assertions.rs @@ -19,15 +19,21 @@ forgetest!(test_fail_deprecation, |prj, cmd| { "#, ); - cmd.forge_fuse().args(["test", "--mc", "DeprecationTestFail"]).assert_failure().stdout_eq( - r#"[COMPILING_FILES] with [SOLC_VERSION] + cmd.forge_fuse() + .args(["test", "--mc", "DeprecationTestFail"]) + .assert_failure() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] ... -[FAIL: `testFail*` has been removed. Consider changing to test_Revert[If|When]_Condition and expecting a revert] Found 2 instances: testFail_deprecated, testFail_deprecated2 ([GAS]) -Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] -... -"#, - ); +Failing tests: +Encountered 2 failing tests in src/DeprecationTestFail.t.sol:DeprecationTestFail +[FAIL: `testFail*` has been removed. Consider changing to test_Revert[If|When]_Condition and expecting a revert] testFail_deprecated() ([GAS]) +[FAIL: `testFail*` has been removed. Consider changing to test_Revert[If|When]_Condition and expecting a revert] testFail_deprecated2() ([GAS]) + +Encountered a total of 2 failing tests, 0 tests succeeded + +"#]]); }); forgetest!(expect_revert_tests_should_fail, |prj, cmd| { diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index d91f19c37b67e..be0db75a33019 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -142,10 +142,6 @@ test_repro!(3347, false, None, |res| { ); }); -// https://github.com/foundry-rs/foundry/issues/3437 -// 1.0 related -// test_repro!(3437); - // https://github.com/foundry-rs/foundry/issues/3596 test_repro!(3596, true, None); @@ -170,10 +166,6 @@ test_repro!( // https://github.com/foundry-rs/foundry/issues/3708 test_repro!(3708); -// https://github.com/foundry-rs/foundry/issues/3723 -// 1.0 related -// test_repro!(3723); - // https://github.com/foundry-rs/foundry/issues/3753 test_repro!(3753); @@ -195,10 +187,6 @@ test_repro!(4630); // https://github.com/foundry-rs/foundry/issues/4640 test_repro!(4640); -// https://github.com/foundry-rs/foundry/issues/4832 -// 1.0 related -// test_repro!(4832); - // https://github.com/foundry-rs/foundry/issues/5038 test_repro!(5038); diff --git a/testdata/default/repros/Issue3437.t.sol b/testdata/default/repros/Issue3437.t.sol deleted file mode 100644 index 69f56ca8283dd..0000000000000 --- a/testdata/default/repros/Issue3437.t.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity >=0.8.18; - -import "ds-test/test.sol"; -import "cheats/Vm.sol"; - -// https://github.com/foundry-rs/foundry/issues/3437 -contract Issue3347Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); - - function internalRevert() internal { - revert(); - } - - function testFailExample() public { - vm.expectRevert(); - internalRevert(); - } -} diff --git a/testdata/default/repros/Issue3723.t.sol b/testdata/default/repros/Issue3723.t.sol deleted file mode 100644 index 9ea3fe733c944..0000000000000 --- a/testdata/default/repros/Issue3723.t.sol +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity >=0.8.18; - -import "ds-test/test.sol"; -import "cheats/Vm.sol"; - -// https://github.com/foundry-rs/foundry/issues/3723 -contract Issue3723Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); - - function testFailExample() public { - vm.expectRevert(); - revert(); - - vm.expectRevert(); - emit log_string("Do not revert"); - } -} diff --git a/testdata/default/repros/Issue4832.t.sol b/testdata/default/repros/Issue4832.t.sol deleted file mode 100644 index 192d805c1bc36..0000000000000 --- a/testdata/default/repros/Issue4832.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity >=0.8.18; - -import "ds-test/test.sol"; -import "cheats/Vm.sol"; - -// https://github.com/foundry-rs/foundry/issues/4832 -contract Issue4832Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); - - function testFailExample() public { - assertEq(uint256(1), 2); - - vm.expectRevert(); - revert(); - } -}