Skip to content
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

fix(config): inline config intermingled #7496

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

grandizzy
Copy link
Collaborator

Motivation

inline config is not properly parsed when multiple tests in same file, for a file with 2 tests like

// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;

import "ds-test/test.sol";

contract FuzzInlineConf is DSTest {
     /// forge-config: default.fuzz.runs = 1
    function testInlineConfFuzz1() {}
}

contract FuzzInlineConf2 is DSTest {
    /// forge-config: default.fuzz.runs = 2
    function testInlineConfFuzz2() {}
}

the natspec parsed for FuzzInlineConf2 is

{ 
  contract: "inline/FuzzInlineConf2.t.sol:FuzzInlineConf2",
  function: "testInlineConfFuzz2", line: "0:0:0",
  docs: "forge-config: default.fuzz.runs = 1\nforge-config: default.fuzz.runs = 2" 
}

instead

{ 
  contract: "inline/FuzzInlineConf2.t.sol:FuzzInlineConf2",
  function: "testInlineConfFuzz2", line: "0:0:0",
  docs: "forge-config: default.fuzz.runs = 2" 
}

This happens due to the fact that FuzzInlineConf2 is the 2nd source unit part but we parse from 0

Solution

parse natspecs from contract definition start location

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty!

@mattsse mattsse merged commit b0698bb into foundry-rs:master Mar 26, 2024
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants