Skip to content

Commit

Permalink
234 config with failure persistence (#508)
Browse files Browse the repository at this point in the history
* [Book] Derive : update proptest-derive to avoid talking about GATs and just refer users to the issue tracker for Strategies of non-owned types

* Add Config::with_failure_persistence

A convenience constructor making use of a generic parameter
over FailurePersistence impls and hiding the Some(Box::new(...)) cruft.

---------

Co-authored-by: Mikhail Zabaluev <[email protected]>
  • Loading branch information
matthew-russo and mzabaluev authored Sep 23, 2024
1 parent 1987e16 commit 0d9f442
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions proptest/src/test_runner/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,32 @@ impl Config {
result
}

/// Constructs a `Config` only differing from the `default()` in the
/// failure_persistence member.
///
/// This is simply a more concise alternative to using field-record update
/// syntax:
///
/// ```
/// # use proptest::test_runner::{Config, FileFailurePersistence};
/// assert_eq!(
/// Config::with_failure_persistence(FileFailurePersistence::WithSource("regressions")),
/// Config {
/// failure_persistence: Some(Box::new(FileFailurePersistence::WithSource("regressions"))),
/// .. Config::default()
/// }
/// );
/// ```
pub fn with_failure_persistence<T>(failure_persistence: T) -> Self
where
T: FailurePersistence + 'static,
{
Self {
failure_persistence: Some(Box::new(failure_persistence)),
..Default::default()
}
}

/// Return whether this configuration implies forking.
///
/// This method exists even if the "fork" feature is disabled, in which
Expand Down

0 comments on commit 0d9f442

Please sign in to comment.