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: add a --no-fuzz or --skip-fuzz flag to skip fuzz tests #1980

Closed
mds1 opened this issue Jun 15, 2022 · 6 comments
Closed

feat: add a --no-fuzz or --skip-fuzz flag to skip fuzz tests #1980

mds1 opened this issue Jun 15, 2022 · 6 comments
Labels
C-forge Command: forge Cmd-forge-test Command: forge test T-feature Type: feature

Comments

@mds1
Copy link
Collaborator

mds1 commented Jun 15, 2022

Component

Forge

Describe the feature you would like

This is useful as you don't always need to run fuzz tests, e.g. when iterating on something, and this can significantly speed up tests. Especially if the fuzz takes make RPC calls, for example.

Right now we always pass in true for the value of include_fuzz_tests, so this should be simple to expose with a flag / config item:

custom_run(self, true)

pub fn custom_run(args: TestArgs, include_fuzz_tests: bool) -> eyre::Result<TestOutcome> {

Workarounds:

  • Test naming conventions like function test_* and function testFuzz_* so you can use the match flags
  • Set the number of fuzz runs to 1 (or even 0, if that works, I haven't tested it)

Additional context

No response

@mds1 mds1 added the T-feature Type: feature label Jun 15, 2022
@mattsse
Copy link
Member

mattsse commented Jun 15, 2022

that makes sense

this would also be a good time refactoring the TestFilter type a bit

there was a recent issue #1908 that highlighted a problem with the Filter.

ideally, everything should be merged from the Config Config -> Filter.

so it would be preferable if we could move that type to config entirely

@onbjerg onbjerg added Cmd-forge-test Command: forge test C-forge Command: forge labels Jun 18, 2022
@onbjerg
Copy link
Member

onbjerg commented Jun 21, 2022

This is most likely a breaking change since the default behavior for forge test is to include fuzz tests, and the default behavior for forge snapshot (that piggybacks off of forge test) is to exclude fuzz tests. I'm not sure how to best unify given Clap doesn't give us a way to override defaults of flattened args :/

The non-breaking path would be to just ignore --no-fuzz/--skip-fuzz in forge snapshot and set those values to !include_fuzz_tests

@onbjerg
Copy link
Member

onbjerg commented Jun 21, 2022

Re @mattsse's comment: ref #1088

@onbjerg
Copy link
Member

onbjerg commented Aug 10, 2022

This is easier to do now that we don't have --include-fuzz-tests on forge snapshot

@mds1
Copy link
Collaborator Author

mds1 commented Aug 10, 2022

FWIW I don't feel too strongly about this feature and am ok with closing this as "not planned". Setting fuzz runs to zero does seem to work as shown below, so I'm not sure this is worth the API clutter

$ FOUNDRY_FUZZ_RUNS=0 forge test

[⠰] Compiling...
No files changed, compilation skipped

Running 1 test for test/MyContract.t.sol:ContractTest
[PASS] testSomething(address,uint224) (runs: 0, μ: 0, ~: 0)
Test result: ok. 1 passed; 0 failed; finished in 833.35µs

@mds1
Copy link
Collaborator Author

mds1 commented Oct 29, 2022

Closing since this can be achieved with zero fuzz runs, or with a good test naming convention and skipping tests with fuzz in the name

@mds1 mds1 closed this as completed Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-test Command: forge test T-feature Type: feature
Projects
Archived in project
Development

No branches or pull requests

3 participants