Repository: trailofbits/test-fuzz (language: rust)

Issue:
Add `--release` flag
I think five steps are necessary:
1. Modify the `TestFuzzWithDeprecations` struct to add the `--release` flag: https://github.com/trailofbits/test-fuzz/blob/42bacfdc5f1b6095862df0e5835b846f3bb5b94e/cargo-test-fuzz/src/bin/cargo_test_fuzz/transition.rs#L26
2. Add a `release` field to this `TestFuzz` struct: https://github.com/trailofbits/test-fuzz/blob/42bacfdc5f1b6095862df0e5835b846f3bb5b94e/cargo-test-fuzz/src/lib.rs#L74
3. Modify this `From` implementation to set the `release` field in the `TestFuzz` struct when that field is set in the `TestFuzzWithDeprecations` struct: https://github.com/trailofbits/test-fuzz/blob/42bacfdc5f1b6095862df0e5835b846f3bb5b94e/cargo-test-fuzz/src/bin/cargo_test_fuzz/transition.rs#L133
4. Modify the `build` function so that it checks whether the `release` field is set, and adds `--release` to the flags passed to `cargo` when it is: https://github.com/trailofbits/test-fuzz/blob/42bacfdc5f1b6095862df0e5835b846f3bb5b94e/cargo-test-fuzz/src/lib.rs#L231
5. Update the "Usage" section in the README: https://github.com/trailofbits/test-fuzz/blob/master/README.md#usage


Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index 54852cb6..c1fa3b60 100644
--- a/README.md
+++ b/README.md
@@ -312,6 +312,7 @@ Options:
   -p, --package <PACKAGE>         Package containing fuzz target
       --persistent                Enable persistent mode fuzzing
       --pretty                    Pretty-print debug output when displaying/replaying
+      --release                   Build in release mode
       --replay <OBJECT>           Replay corpus, crashes, hangs, or work queue. By default, an
                                   uninstrumented fuzz target is used. To replay with instrumentation
                                   append `-instrumented` to <OBJECT>, e.g., --replay


Test patch:
diff --git a/cargo-test-fuzz/src/bin/cargo_test_fuzz/transition.rs b/cargo-test-fuzz/src/bin/cargo_test_fuzz/transition.rs
index f530caf0..36d23dd0 100644
--- a/cargo-test-fuzz/src/bin/cargo_test_fuzz/transition.rs
+++ b/cargo-test-fuzz/src/bin/cargo_test_fuzz/transition.rs
@@ -93,6 +93,8 @@ struct TestFuzzWithDeprecations {
         alias = "pretty-print"
     )]
     pretty: bool,
+    #[arg(long, help = "Build in release mode")]
+    release: bool,
     #[arg(
         long,
         value_name = "OBJECT",
@@ -166,6 +168,7 @@ impl From<TestFuzzWithDeprecations> for super::TestFuzz {
             package,
             persistent,
             pretty,
+            release,
             replay,
             reset,
             reset_all,
@@ -202,6 +205,7 @@ impl From<TestFuzzWithDeprecations> for super::TestFuzz {
             package,
             persistent,
             pretty,
+            release,
             replay,
             reset,
             reset_all,
diff --git a/cargo-test-fuzz/src/lib.rs b/cargo-test-fuzz/src/lib.rs
index 8c2a1860..7bfe4d26 100644
--- a/cargo-test-fuzz/src/lib.rs
+++ b/cargo-test-fuzz/src/lib.rs
@@ -86,6 +86,7 @@ pub struct TestFuzz {
     pub package: Option<String>,
     pub persistent: bool,
     pub pretty: bool,
+    pub release: bool,
     pub replay: Option<Object>,
     pub reset: bool,
     pub reset_all: bool,
@@ -255,6 +256,9 @@ fn build(opts: &TestFuzz, use_instrumentation: bool, quiet: bool) -> Result<Vec<
     for features in &opts.features {
         args.extend_from_slice(&["--features", features]);
     }
+    if opts.release {
+        args.extend_from_slice(&["--release"]);
+    }
     let target_dir = target_directory(true);
     let target_dir_str = target_dir.to_string_lossy();
     if use_instrumentation {