Is it possible somehow to skip compilation when testing with foundry? I have a lot of contracts in the src map but there is only 1 file in a test map and whenever I run foundry test the compilation takes above 3 minutes to wait because it compiles all files from src however I don't need them. In foundry.toml I do have a field - test = 'test/foundry'. I tried to specify contract/test/path like forge test --match-contract test.t.sol --math-test testHash but it doesn't help. So whenever I change any letter in the test file I have to wait around 3 minutes. Any thoughts?

Would be really grateful for any help.

3 Answers 3


We recently added forge build --skip <...>. So you can do forge build --skip test link and that will only compile src/.

We also recently trimmed down forge-std for v1.2 so compilation times with via-ir should be down as well.

LMK if this helps.


It's probably because of via-ir changes.

See this

You can try to revert foundry to v0.3 with

forge install foundry-rs/forge-std@c19dfd2f2a88a461216b0dd1f4961e1a85dcad46

Hope this helps


Found a solution on the opensea project. I suppose they had a similar problem so in the foundry.toml they specified a new profile - profile.test where they override the src field from 'contracts' to 'test/foundry' so whenever you want to run tests just set the environment variable FOUNDRY_PROFILE="test" and just run them. It will compile only files from test/foundry.

src = 'contracts'

src = 'test/foundry'

For windows

$env:FOUNDRY_PROFILE = "test"

forge test

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.