Skip to content

forge test --rerun should rerun failing fuzz test input #8629

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
tynes opened this issue Aug 8, 2024 · 4 comments
Closed

forge test --rerun should rerun failing fuzz test input #8629

tynes opened this issue Aug 8, 2024 · 4 comments
Labels
A-testing Area: testing C-forge Command: forge Cmd-forge-test Command: forge test T-bug Type: bug

Comments

@tynes
Copy link
Contributor

tynes commented Aug 8, 2024

Component

Forge

Describe the feature you would like

I am currently experiencing a situation in which forge test --rerun does indeed rerun a failed test but the failed test is a fuzz test and it is not always capturing the failure in the fuzz test. Ideally the cached output for the failure should include the fuzz inputs that triggered the failure and those are specifically used as inputs during the call with --rerun so that the failure trace can be inspected with -vvv

Additional context

No response

@tynes tynes added T-feature Type: feature T-needs-triage Type: this issue needs to be labelled labels Aug 8, 2024
@tynes
Copy link
Contributor Author

tynes commented Aug 9, 2024

@grandizzy
Copy link
Collaborator

grandizzy commented Aug 9, 2024

@tynes does your CI use same cache dir for subsequent runs? The saved fuzz failure counterexample needs to be available in cache dir when rerun, pls see

https://book.getfoundry.sh/forge/replay-testing#fuzz-tests-failures

you can locally check this functionality by using a test contract like

contract ContractTest is Test {
    function testA() public {
        require(true);
    }

    function testB() public {
        require(true);
    }

    function testC(uint256 a) public {
        require(a != 0);
    }
}

on the first forge test --rerun will show failure caught after 31 runs

[PASS] testA() (gas: 187)
[PASS] testB() (gas: 165)
[FAIL. Reason: EvmError: Revert; counterexample: calldata=0xf280cf450000000000000000000000000000000000000000000000000000000000000000 args=[0]] testC(uint256) (runs: 31, μ: 312, ~: 312)

while the next one runs only the failed test with failed counterexample (runs is 0)

Ran 1 test for test/ContractTest.sol:ContractTest
[FAIL. Reason: EvmError: Revert; counterexample: calldata=0xf280cf450000000000000000000000000000000000000000000000000000000000000000 args=[0]] testC(uint256) (runs: 0, μ: 0, ~: 0)

@zerosnacks zerosnacks added A-testing Area: testing T-bug Type: bug C-forge Command: forge Cmd-forge-test Command: forge test and removed T-needs-triage Type: this issue needs to be labelled T-feature Type: feature labels Aug 9, 2024
@mds1
Copy link
Collaborator

mds1 commented Aug 9, 2024

@tynes Going to close this issue since I believe --rerun was working properly and what we really saw is #8639

@mds1 mds1 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2024
@tynes
Copy link
Contributor Author

tynes commented Aug 9, 2024

Thank you @grandizzy for the help!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-testing Area: testing C-forge Command: forge Cmd-forge-test Command: forge test T-bug Type: bug
Projects
None yet
Development

No branches or pull requests

4 participants