Skip to content

Commit

Permalink
Config : support disabling failure persistence via env var (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-russo authored Jan 14, 2023
1 parent 7a94e16 commit b513a32
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions proptest/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

- Add `Arbitrary` impls for arrays of all sizes using const generics
- Add `Arbitrary` impls for `core::num::NonZero*`
- Adds ability to disable failure persistence via env var `PROPTEST_DISABLE_FAILURE_PERSISTENCE`

## 1.0.0

Expand Down
19 changes: 16 additions & 3 deletions proptest/src/test_runner/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ const FORK: &str = "PROPTEST_FORK";
const TIMEOUT: &str = "PROPTEST_TIMEOUT";
#[cfg(feature = "std")]
const VERBOSE: &str = "PROPTEST_VERBOSE";
#[cfg(feature = "std")]
const RNG_ALGORITHM: &str = "PROPTEST_RNG_ALGORITHM";
#[cfg(feature = "std")]
const DISABLE_FAILURE_PERSISTENCE: &str = "PROPTEST_DISABLE_FAILURE_PERSISTENCE";

#[cfg(feature = "std")]
fn contextualize_config(mut result: Config) -> Config {
Expand Down Expand Up @@ -124,6 +127,9 @@ fn contextualize_config(mut result: Config) -> Config {
"RngAlgorithm",
RNG_ALGORITHM,
),
DISABLE_FAILURE_PERSISTENCE => {
result.failure_persistence = None
}

_ => {
if var.starts_with("PROPTEST_") {
Expand Down Expand Up @@ -223,7 +229,11 @@ pub struct Config {
/// See the docs of [`FileFailurePersistence`](enum.FileFailurePersistence.html)
/// and [`MapFailurePersistence`](struct.MapFailurePersistence.html) for more information.
///
/// The default cannot currently be overridden by an environment variable.
/// You can disable failure persistence with the `PROPTEST_DISABLE_FAILURE_PERSISTENCE`
/// environment variable but its not currently possible to set the persistence file
/// with an environment variable. (The variable is
/// only considered when the `std` feature is enabled, which it is by
/// default.)
pub failure_persistence: Option<Box<dyn FailurePersistence>>,

/// File location of the current test, relevant for persistence
Expand Down Expand Up @@ -258,7 +268,9 @@ pub struct Config {
/// This requires the "fork" feature, enabled by default.
///
/// The default is `false`, which can be overridden by setting the
/// `PROPTEST_FORK` environment variable.
/// `PROPTEST_FORK` environment variable. (The variable is
/// only considered when the `std` feature is enabled, which it is by
/// default.)
#[cfg(feature = "fork")]
pub fork: bool,

Expand Down Expand Up @@ -346,7 +358,8 @@ pub struct Config {
/// since on nostd proptest has no way to produce output.
///
/// The default is `0`, which can be overridden by setting the
/// `PROPTEST_VERBOSE` environment variable.
/// `PROPTEST_VERBOSE` environment variable. (The variable is only considered
/// when the `std` feature is enabled, which it is by default.)
#[cfg(feature = "std")]
pub verbose: u32,

Expand Down

0 comments on commit b513a32

Please sign in to comment.