solidity – How to Make Foundry Skip Compilation on Test

foundrysolidity

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.

Best Answer

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.