diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d26a71d..d0073221 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -130,7 +130,6 @@ jobs: package: [third-party, other] serde_format: [bincode, postcard] toolchain: [stable, nightly] - self_ty_in_mod_name: [false, true] steps: - uses: actions/checkout@v4 @@ -188,10 +187,9 @@ jobs: if [[ ${{ matrix.toolchain }} = nightly ]]; then SHUFFLE='-Z unstable-options --shuffle --test-threads=1' fi - SELF_TY_IN_MOD_NAME="$(${{ matrix.self_ty_in_mod_name }} && echo '--features test-fuzz/self_ty_in_mod_name')" || true CONFIG_GROUP_RUNNER="--config target.'cfg(all())'.runner='group-runner'" - BUILD_CMD="cargo build $MAYBE_THIRD_PARTY $SERDE_FORMAT $SELF_TY_IN_MOD_NAME --all-targets" - TEST_CMD="cargo test $MAYBE_THIRD_PARTY $SERDE_FORMAT $SELF_TY_IN_MOD_NAME $CONFIG_GROUP_RUNNER -- --nocapture $SHUFFLE" + BUILD_CMD="cargo build $MAYBE_THIRD_PARTY $SERDE_FORMAT --all-targets" + TEST_CMD="cargo test $MAYBE_THIRD_PARTY $SERDE_FORMAT $CONFIG_GROUP_RUNNER -- --nocapture $SHUFFLE" echo "BUILD_CMD=$BUILD_CMD" >> "$GITHUB_ENV" echo "TEST_CMD=$TEST_CMD" >> "$GITHUB_ENV" diff --git a/README.md b/README.md index e10376fa..da8f273c 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,12 @@ Note, however, that just because a target was called with certain parameters dur ##### `rename = "name"` -Treat the target as though its name is `name` when adding a module to the enclosing scope. Expansion of the `test_fuzz` macro adds a module definition to the enclosing scope. Currently, the module is named `target_fuzz`, where `target` is the name of the target. Use of this option causes the module to instead be be named `name_fuzz`. Example: +Treat the target as though its name is `name` when adding a module to the enclosing scope. Expansion of the `test_fuzz` macro adds a module definition to the enclosing scope. By default, the module is named as follows: + +- If the target does not appear in an `impl` block, the module is named `target_fuzz`, where `target` is the name of the target. +- If the target appears in an `impl` block, the module is named `path_target_fuzz`, where `path` is the path of the `impl`'s `Self` type converted to snake case and joined with `_`. + +However, use of this option causes the module to instead be named `name_fuzz`. Example: ```rust #[test_fuzz(rename = "bar")] @@ -329,7 +334,7 @@ impl<'de> serde::Deserialize<'de> for $ty { } ``` -If `$ty` is a unit struct, then `$expr` can be be omitted. That is, `dont_care!($ty)` is equivalent to `dont_care!($ty, $ty)`. +If `$ty` is a unit struct, then `$expr` can be omitted. That is, `dont_care!($ty)` is equivalent to `dont_care!($ty, $ty)`. #### `leak!` @@ -397,10 +402,10 @@ where ## `test-fuzz` package features -The features in this section apply to the `test-fuzz` package as a whole. Enable them in `test-fuzz`'s dependency specification as described in the [The Cargo Book]. For example, to enable the `self_ty_in_mod_name` feature, use: +The features in this section apply to the `test-fuzz` package as a whole. Enable them in `test-fuzz`'s dependency specification as described in the [The Cargo Book]. For example, to enable the `cast_checks` feature, use: ```toml -test-fuzz = { version = "*", features = ["self_ty_in_mod_name"] } +test-fuzz = { version = "*", features = ["cast_checks"] } ``` The `test-fuzz` package currently supports the following features: @@ -409,12 +414,6 @@ The `test-fuzz` package currently supports the following features: Use [`cast_checks`] to automatically check target functions for invalid casts. -### `self_ty_in_mod_name` - -Incorporate an `impl`'s `Self` type into the names of modules generated for the `impl`. Expansion of the `test_fuzz` macro adds a module definition to the enclosing scope. By default, the module is named `target_fuzz`, where `target` is the name of the target. If the target appears in an `impl` block, then use of this feature causes the module to instead be named `path_target_fuzz`, where `path` is the path of the `impl`'s `Self` type converted to snake case and joined with `_`. (See also [`rename`] above.) - -In a future version of `test-fuzz`, this behavior will be the default. - ### Serde formats `test-fuzz` can serialize target arguments in multiple Serde formats. The following are the features used to select a format. diff --git a/cargo-test-fuzz/tests/integration/fuzz_generic.rs b/cargo-test-fuzz/tests/integration/fuzz_generic.rs index 55dbac6a..e3fd9f17 100644 --- a/cargo-test-fuzz/tests/integration/fuzz_generic.rs +++ b/cargo-test-fuzz/tests/integration/fuzz_generic.rs @@ -24,19 +24,21 @@ static MUTEX: Mutex<()> = Mutex::new(()); fn fuzz(test: &str, code: i32) { let _lock = MUTEX.lock().unwrap(); - let corpus = corpus_directory_from_target("generic", "target"); + let corpus = corpus_directory_from_target("generic", "struct_target"); // smoelius: This call to `remove_dir_all` is protected by the mutex above. #[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))] - remove_dir_all(corpus).unwrap_or_default(); + remove_dir_all(&corpus).unwrap_or_default(); examples::test("generic", test) .unwrap() .logged_assert() .success(); + assert!(corpus.exists()); + retry(3, || { - examples::test_fuzz("generic", "target") + examples::test_fuzz("generic", "struct_target") .unwrap() .args([ "--exit-code", diff --git a/cargo-test-fuzz/tests/integration/generic_args.rs b/cargo-test-fuzz/tests/integration/generic_args.rs index 93cf1c38..d866deb2 100644 --- a/cargo-test-fuzz/tests/integration/generic_args.rs +++ b/cargo-test-fuzz/tests/integration/generic_args.rs @@ -10,21 +10,21 @@ fn generic() { test( "generic", "test_bound", - "target_bound", + "struct_target_bound", &impl_expected, &expected, ); test( "generic", "test_where_clause", - "target_where_clause", + "struct_target_where_clause", &impl_expected, &expected, ); test( "generic", "test_only_generic_args", - "target_only_generic_args", + "struct_target_only_generic_args", &impl_expected, &expected, ); diff --git a/macro/Cargo.toml b/macro/Cargo.toml index 2600e7c5..8d6918da 100644 --- a/macro/Cargo.toml +++ b/macro/Cargo.toml @@ -14,7 +14,7 @@ proc-macro = true [dependencies] darling = { workspace = true } -heck = { workspace = true, optional = true } +heck = { workspace = true } itertools = { workspace = true } once_cell = { workspace = true } prettyplease = { workspace = true } @@ -25,7 +25,6 @@ syn = { workspace = true } [features] __cast_checks = [] __persistent = [] -__self_ty_in_mod_name = ["heck"] [lints] workspace = true diff --git a/macro/src/lib.rs b/macro/src/lib.rs index de4c0ea2..49162510 100644 --- a/macro/src/lib.rs +++ b/macro/src/lib.rs @@ -1070,7 +1070,6 @@ fn mod_ident(opts: &TestFuzzOpts, self_ty_base: Option<&Ident>, target_ident: &I if let Some(name) = &opts.rename { s.push_str(&name.to_string()); } else { - #[cfg(feature = "__self_ty_in_mod_name")] if let Some(ident) = self_ty_base { s.push_str(&::to_snake_case( &ident.to_string(), diff --git a/test-fuzz/Cargo.toml b/test-fuzz/Cargo.toml index 599882ef..c72d27ee 100644 --- a/test-fuzz/Cargo.toml +++ b/test-fuzz/Cargo.toml @@ -36,7 +36,6 @@ testing = { workspace = true } [features] cast_checks = ["dep:cast_checks", "test-fuzz-macro/__cast_checks"] -self_ty_in_mod_name = ["test-fuzz-macro/__self_ty_in_mod_name"] serde_bincode = ["internal/__serde_bincode"] serde_postcard = ["internal/__serde_postcard"] __persistent = ["afl", "test-fuzz-macro/__persistent"] diff --git a/test-fuzz/tests/integration/self_ty_in_mod_name.rs b/test-fuzz/tests/integration/self_ty_in_mod_name.rs index c49f99b5..8a332c37 100644 --- a/test-fuzz/tests/integration/self_ty_in_mod_name.rs +++ b/test-fuzz/tests/integration/self_ty_in_mod_name.rs @@ -10,16 +10,12 @@ fn success() { command.assert().success(); } -#[cfg_attr(not(feature = "self_ty_in_mod_name"), ignore)] #[test] fn self_ty_conflict() { let mut command = test(); command - .args([ - "--features=test-fuzz/self_ty_in_mod_name", - "--features=__self_ty_conflict", - ]) + .args(["--features=__self_ty_conflict"]) .assert() .failure() .stderr(predicate::str::contains( diff --git a/third-party/patches/solana_rbpf.patch b/third-party/patches/solana_rbpf.patch index 05a95f26..22569b39 100644 --- a/third-party/patches/solana_rbpf.patch +++ b/third-party/patches/solana_rbpf.patch @@ -6,7 +6,7 @@ index 781ce87..2a667b6 100644 thiserror = "1.0.26" +serde = "1.0" -+test-fuzz = { path = "../../test-fuzz", features = ["self_ty_in_mod_name"] } ++test-fuzz = { path = "../../test-fuzz" } + [target.'cfg(windows)'.dependencies] winapi = { version = "0.3", features = ["memoryapi", "sysinfoapi", "winnt", "errhandlingapi"], optional = true }