-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug(forge test
): --fail-fast
flag does not work as it is not applied across multiple test suites
#6529
Comments
looking at code it looks like // SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {Test, console2} from "forge-std/Test.sol";
import {Counter} from "../src/Counter.sol";
contract ACounterTest is Test {
Counter public counter;
function setUp() public {
counter = new Counter();
counter.setNumber(0);
}
function test_Increment() public {
assertTrue(false);
}
function testFuzz_AnotherSetNumber(uint256 x) public {
counter.setNumber(x);
assertEq(counter.number(), x);
}
}
contract BCounterTest is Test {
Counter public counter;
function setUp() public {
counter = new Counter();
counter.setNumber(0);
}
function testFuzz_SetNumber(uint256 x) public {
counter.setNumber(x);
assertEq(counter.number(), x);
}
} if running without flag then both contracts are tested (even though FOUNDRY_FUZZ_RUNS=2000 forge test
Ran 2 tests for test/Counter.t.sol:ACounterTest
[PASS] testFuzz_AnotherSetNumber(uint256) (runs: 2000, μ: 27500, ~: 28366)
[FAIL. Reason: assertion failed] test_Increment() (gas: 10766)
Test result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 97.51ms
Ran 1 test for test/Counter.t.sol:BCounterTest
[PASS] testFuzz_SetNumber(uint256) (runs: 2000, μ: 27630, ~: 28387)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 99.50ms
Ran 2 test suites in 197.01ms: 2 tests passed, 1 failed, 0 skipped (3 total tests)
Failing tests:
Encountered 1 failing test in test/Counter.t.sol:ACounterTest
[FAIL. Reason: assertion failed] test_Increment() (gas: 10766)
Encountered a total of 1 failing tests, 2 tests succeeded when run with fail fast the 2nd suite is not executed anymore FOUNDRY_FUZZ_RUNS=2000 forge test --fail-fast
Ran 2 tests for test/Counter.t.sol:ACounterTest
[PASS] testFuzz_AnotherSetNumber(uint256) (runs: 2000, μ: 27540, ~: 28366)
[FAIL. Reason: assertion failed] test_Increment() (gas: 10766)
Test result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 99.20ms
Ran 1 test suite in 99.20ms: 1 tests passed, 1 failed, 0 skipped (2 total tests)
Failing tests:
Encountered 1 failing test in test/Counter.t.sol:ACounterTest
[FAIL. Reason: assertion failed] test_Increment() (gas: 10766)
Encountered a total of 1 failing tests, 1 tests succeeded looks like a design choice not a bug? |
proposed way to interrupt runs for fuzz / invariant tests proptest-rs/proptest#460 to be applied in addition to using rayon collect / short-circuit on |
Just confirming this is still an active issue, setup as described still yields:
|
--fail-fast
flag does not workforge test
): --fail-fast
flag does not work as it is not applied across multiple test suites
This is very annoying, would love for this to not be the case :/ |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (13af418 2023-12-05T00:21:30.568484000Z)
What command(s) is the bug in?
forge test --fail-fast
Operating System
None
Describe the bug
Running
FOUNDRY_FUZZ_RUNS=100000 forge test --fail-fast
on the below code should runtest_Increment
andtestFuzz_SetNumber
in parallel, and failtest_Increment
should fail immediately. However,forge test
does not fail and exit until all 100,000 fuzz runs completeThe text was updated successfully, but these errors were encountered: