rust-fuzz / cargo-fuzz

Command line helpers for fuzzing
https://rust-fuzz.github.io/book/cargo-fuzz.html
Apache License 2.0
1.53k stars 109 forks source link

'cargo fuzz clean' ? #361

Closed cameronelliott closed 7 months ago

cameronelliott commented 7 months ago

Hi, One thing that seems like it would be useful is a cargo fuzz clean sub-command which would be equivalent to rm -rf fuzz/target

This is helpful as I don't think the 'cargo fuzz check' dependency graph is perfect, and sometimes, you (I) want to do a check from zero to make sure a few odd tweaks are passing a 100% from zero cargo fuzz check

Of course now, I just use rm -rf fuzz/target, but this might be useful.

Also, thanks to the repo-contribs writing this fuzzer, I will say it is super useful. I am using it to fuzz-out a re-write of C to rust, and it's vastly superior to writing unit tests in many cases.

fitzgen commented 7 months ago

Glad you are enjoying cargo fuzz! I also find fuzzing superior to unit tests in many cases, although of course neither is a full replacement for the other in all situations.


If your fuzz directory is in a separate workspace from the rest of your project (which it almost assuredly is if you have a fuzz/target directory) then running plain cargo clean inside the fuzz directory should suffice.

(And for completeness, if the fuzz crate was in the same workspace as the rest of the project, then project/target would be used for build artifacts rather than project/fuzz/target and running cargo clean would clean up the fuzzing build artifacts in project/target as well.)

Therefore, I'm not convinced it is worth adding a cargo fuzz clean command since it should be the exact same as cargo clean in all cases. But perhaps I am overlooking something?

cameronelliott commented 7 months ago

Oh! you are so right!

I shouldn't be trying to shoehorn all my actions into cargo fuzz ... but rather doing some cd fuzz ; cargo [clean, check, ...]

Thanks for pointing this out!

I was also thinking cargo fuzz check needed a --quiet flags for my needs, but really I should be doing cargo ops from the fuzz dir, like you said.

🙂