Skip to content

bug(forge test --debug): debugger does not open if setUp reverts #10322

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

Open
2 tasks done
e1Ru1o opened this issue Apr 17, 2025 · 1 comment
Open
2 tasks done

bug(forge test --debug): debugger does not open if setUp reverts #10322

e1Ru1o opened this issue Apr 17, 2025 · 1 comment
Labels
A-debugger Area: debugger Cmd-forge-test Command: forge test T-bug Type: bug T-to-investigate Type: to investigate

Comments

@e1Ru1o
Copy link

e1Ru1o commented Apr 17, 2025

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge Version: 1.0.0-stable Commit SHA: e144b82

What version of Foundryup are you on?

foundryup: 1.0.1

What command(s) is the bug in?

forge test --mt someTest --debug

Operating System

macOS (Apple Silicon)

Describe the bug

Tests where the setUp fail don't open the debugger. E.g.

import {Test} from "@forge-std/Test.sol";

contract TestTest is Test {
    function setUp() public {
        revert();
    }

    function testFoo() public {}
}

Then forge test --mc TestTest --debug just fails

@e1Ru1o e1Ru1o added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Apr 17, 2025
@github-project-automation github-project-automation bot moved this to Todo in Foundry Apr 17, 2025
@zerosnacks zerosnacks changed the title Debug doesn't work on test if setUp reverts bug(forge test --debug): debugger does not open if setUp reverts Apr 17, 2025
@zerosnacks zerosnacks added Cmd-forge-test Command: forge test A-debugger Area: debugger and removed T-needs-triage Type: this issue needs to be labelled labels Apr 17, 2025
@zerosnacks
Copy link
Member

able to reproduce with setup:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test, console} from "forge-std/Test.sol";
import {Counter} from "../src/Counter.sol";

contract CounterTest is Test {
    Counter public counter;

    function setUp() public {
        counter = new Counter();
        counter.setNumber(0);

        revert();
    }

    function test_Increment() public {
        counter.increment();
        assertEq(counter.number(), 1);
    }

    function testFuzz_SetNumber(uint256 x) public {
        counter.setNumber(x);
        assertEq(counter.number(), x);
    }
}
forge test --debug --match-path test/Counter.t.sol --mt test_Increment
[⠊] Compiling...
[⠆] Compiling 1 files with Solc 0.8.29
[⠰] Solc 0.8.29 finished in 240.44ms
Compiler run successful!

Ran 1 test for test/Counter.t.sol:CounterTest
[FAIL: EvmError: Revert] setUp() (gas: 0)
Suite result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 270.22µs (0.00ns CPU time)

Ran 1 test suite in 2.59ms (270.22µs CPU time): 0 tests passed, 1 failed, 0 skipped (1 total tests)
Error: debug arena is empty

@zerosnacks zerosnacks added the T-to-investigate Type: to investigate label Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debugger Area: debugger Cmd-forge-test Command: forge test T-bug Type: bug T-to-investigate Type: to investigate
Projects
Status: Todo
Development

No branches or pull requests

2 participants