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

feat: allow any config to be defined inline #9430

Merged
merged 8 commits into from
Dec 2, 2024

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Nov 29, 2024

Allow any configuration value to be defined inline using the same TOML syntax as foundry.toml.

This is achieved by updating Config, Executor etc. fields with the new inline Config value saved in a TestRunnerConfig field for each level of tests:

  • MultiContractRunner, global
  • ContractRunner, contract-level, applied before running any EVM code
  • FunctionRunner (new), function-level, applied before running each test

TestRunnerConfig is inherited from the level before, and updated with inline config whenever it's available.

Not all configs will do something at every level; for example the fork stuff is spawned at contract-level so changing that at function level won't have any effect, but for that there is cheatcodes.

TestOptions's functionality has been moved to FunctionRunner.

Closes #8564.
Closes #6908.
Closes #6228.

Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

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

Awesome stuff! gave #6228 (comment) a try with inline paris and shanghai and works great. I think this PR should close #6228 too per #6228 (comment) (1st and 3rd bullets are covered in this PR, the 2nd bullet / automatic detection is tracked in #6440)

should we clean up tests a little bit too (like merging testdata/paris in testdata/default and removing the TEST_DATA_PARIS / paris ForgeTestProfile profile and using inline config for specifying the evm version), or better to keep separate profiles? (I can follow up in a PR after we merge this one)

crates/forge/tests/cli/inline_config.rs Show resolved Hide resolved
Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

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

lgtm!

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.

hell yeah

@DaniPopes DaniPopes enabled auto-merge (squash) December 2, 2024 14:41
@DaniPopes DaniPopes merged commit 3e6d3b8 into master Dec 2, 2024
21 checks passed
@DaniPopes DaniPopes deleted the dani/full-inline-config branch December 2, 2024 14:55
@grandizzy grandizzy added T-feature Type: feature C-forge Command: forge labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge T-feature Type: feature
Projects
Archived in project
4 participants