Skip to content

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Aug 28, 2025

  • get_sources_to_compile currently is always called, even when there are no filters to apply to the input. This is wasteful because it will compile all sources to ABI, filter out nothing, then recompile everything again for bytecode regardless
  • we want to filter out non-matching test contracts, instead of filtering out everything and then adding back sources. This misses scripts and other stray files
  • Added in feat(test): only compile files needed for tests #7334, this changed the exit code to fail when there are no tests, which I don't think is right and doesn't match other test frameworks
  • move the "no matching test" check back to run_tests to simplify the function and so we can also handle the case when there are no tests at all in the project

@DaniPopes DaniPopes force-pushed the dani/get_sources_to_compile branch from 4fc020c to 996cea7 Compare August 28, 2025 21:52
cmd.args(["test"]).with_no_redact().assert_success().stdout_eq(str![[r#"
...
Compiling 21 files with [..]
Compiling 23 files with [..]
Copy link
Member Author

Choose a reason for hiding this comment

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

the extra 2 files are script/Counter.s.sol and forge-std/Script.sol

Copy link
Member

Choose a reason for hiding this comment

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

the idea for get_sources_to_compile was that we don't want to compile e.g scripts for forge test, is this no longer the case?

Copy link
Member Author

Choose a reason for hiding this comment

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

My hunch was that in practice it ends up being slower to compile another time before to filter out unneeded files than to just run the pipeline normally; I can revisit further by rewriting to solar

@onbjerg onbjerg merged commit 6aedaea into master Aug 29, 2025
23 checks passed
@onbjerg onbjerg deleted the dani/get_sources_to_compile branch August 29, 2025 22:50
@github-project-automation github-project-automation bot moved this to Done in Foundry Aug 29, 2025
@DaniPopes DaniPopes self-assigned this Sep 1, 2025
@grandizzy grandizzy moved this from Done to Completed in Foundry Sep 1, 2025
MerkleBoy pushed a commit to MerkleBoy/foundry that referenced this pull request Sep 17, 2025
* refactor: test filter

* refactor: handling of empty test filters

* dontfail

* fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants