foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.25k stars 1.73k forks source link

feat(`forge test`): add `--skip` flag for forge test to skip compilation of specific files or folders #9164

Open wjorgensen opened 4 days ago

wjorgensen commented 4 days ago

Component

Forge

Describe the feature you would like

There is a skip flag for forge build but no skip flag for forge test when it builds the project. I want to be able to skip compilation of non essential files when I'm only testing one specific file or function. In addition to a general skip flag when I use the --match-contract and --match-test flags there should be a flag to only compile the files that are used by the contract or test.

Desired behavior

forge test --skip /script

Skips the compilation of all files in the script folder

forge test --match-contract Test1 --skip

Only compiles files imported and used within the Test1 contract.

Additional context

For context why I am asking for this feature is because I am building a tool called Solidings which is a version of Rustlings but for solidity. I'm trying to use foundry tests to check for completion of files but I can't run forge test because it compiles all of the files in the project every time it runs even when I'm running --match-contract or --match-test. This means that for forge test to be able to run the user must complete all of the files in the entire project. This doesn't work because just like Rustlings I would like for the user to be able to check each file as the complete them.

zerosnacks commented 3 days ago

Related: https://github.com/foundry-rs/compilers/issues/197

cuiweixie commented 3 days ago

If this feature is accept, can I try to develop this feature.

klkvr commented 2 days ago

I believe this should already work like this. Right now forge test would only compiled filtered test files. And --skip is also available

ref https://github.com/foundry-rs/foundry/pull/7334