Struct FuzzConfig
pub struct FuzzConfig {Show 15 fields
pub cases: u32,
pub max_local_rejects: u32,
pub max_global_rejects: u32,
pub max_flat_map_regens: u32,
pub failure_persistence: Option<Box<dyn FailurePersistence>>,
pub source_file: Option<&'static str>,
pub test_name: Option<&'static str>,
pub fork: bool,
pub timeout: u32,
pub max_shrink_time: u32,
pub max_shrink_iters: u32,
pub max_default_size_range: usize,
pub result_cache: fn() -> Box<dyn ResultCache>,
pub verbose: u32,
pub rng_algorithm: RngAlgorithm,
/* private fields */
}
Expand description
Configuration for how a proptest test should be run.
Fields§
§cases: u32
The number of successful test cases that must execute for the test as a whole to pass.
This does not include implicitly-replayed persisted failing cases.
The default is 256, which can be overridden by setting the
PROPTEST_CASES
environment variable. (The variable is only considered
when the std
feature is enabled, which it is by default.)
max_local_rejects: u32
The maximum number of individual inputs that may be rejected before the test as a whole aborts.
The default is 65536, which can be overridden by setting the
PROPTEST_MAX_LOCAL_REJECTS
environment variable. (The variable is only
considered when the std
feature is enabled, which it is by default.)
max_global_rejects: u32
The maximum number of combined inputs that may be rejected before the test as a whole aborts.
The default is 1024, which can be overridden by setting the
PROPTEST_MAX_GLOBAL_REJECTS
environment variable. (The variable is
only considered when the std
feature is enabled, which it is by
default.)
max_flat_map_regens: u32
The maximum number of times all Flatten
combinators will attempt to
regenerate values. This puts a limit on the worst-case exponential
explosion that can happen with nested Flatten
s.
The default is 1_000_000, which can be overridden by setting the
PROPTEST_MAX_FLAT_MAP_REGENS
environment variable. (The variable is
only considered when the std
feature is enabled, which it is by
default.)
failure_persistence: Option<Box<dyn FailurePersistence>>
Indicates whether and how to persist failed test results.
When compiling with “std” feature (i.e. the standard library is available), the default
is Some(Box::new(FileFailurePersistence::SourceParallel("proptest-regressions")))
.
Without the standard library, the default is None
, and no persistence occurs.
See the docs of FileFailurePersistence
and MapFailurePersistence
for more information.
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.)
source_file: Option<&'static str>
File location of the current test, relevant for persistence and debugging.
Note the use of &str
rather than Path
to be compatible with
#![no_std]
use cases where Path
is unavailable.
See the docs of FileFailurePersistence
for more information on how it may be used for persistence.
test_name: Option<&'static str>
The fully-qualified name of the test being run, as would be passed to the test executable to run just that test.
This must be set if fork
is true
. Otherwise, it is unused. It is
automatically set by proptest!
.
This must include the crate name at the beginning, as produced by
module_path!()
.
fork: bool
fork
only.If true, tests are run in a subprocess.
Forking allows proptest to work with tests which may fail by aborting the process, causing a segmentation fault, etc, but can be a lot slower in certain environments or when running a very large number of tests.
For forking to work correctly, both the Strategy
and the content of
the test case itself must be deterministic.
This requires the “fork” feature, enabled by default.
The default is false
, which can be overridden by setting the
PROPTEST_FORK
environment variable. (The variable is
only considered when the std
feature is enabled, which it is by
default.)
timeout: u32
timeout
only.If non-zero, tests are run in a subprocess and each generated case fails if it takes longer than this number of milliseconds.
This implicitly enables forking, even if the fork
field is false
.
The type here is plain u32
(rather than
Option<std::time::Duration>
) for the sake of ergonomics.
This requires the “timeout” feature, enabled by default.
Setting a timeout to less than the time it takes the process to start up and initialise the first test case will cause the whole test to be aborted.
The default is 0
(i.e., no timeout), which can be overridden by
setting the PROPTEST_TIMEOUT
environment variable. (The variable is
only considered when the std
feature is enabled, which it is by
default.)
max_shrink_time: u32
std
only.If non-zero, give up the shrinking process after this many milliseconds have elapsed since the start of the shrinking process.
This will not cause currently running test cases to be interrupted.
This configuration is only available when the std
feature is enabled
(which it is by default).
The default is 0
(i.e., no limit), which can be overridden by setting
the PROPTEST_MAX_SHRINK_TIME
environment variable. (The variable is
only considered when the std
feature is enabled, which it is by
default.)
max_shrink_iters: u32
Give up on shrinking if more than this number of iterations of the test code are run.
Setting this to std::u32::MAX
causes the actual limit to be four
times the number of test cases.
Setting this value to 0
disables shrinking altogether.
Note that the type of this field will change in a future version of proptest to better accommodate its special values.
The default is std::u32::MAX
, which can be overridden by setting the
PROPTEST_MAX_SHRINK_ITERS
environment variable. (The variable is only
considered when the std
feature is enabled, which it is by default.)
max_default_size_range: usize
The default maximum size to proptest::collection::SizeRange
. The default
strategy for collections (like Vec
) use collections in the range of
0..max_default_size_range
.
The default is 100
which can be overridden by setting the
PROPTEST_MAX_DEFAULT_SIZE_RANGE
environment variable. (The variable
is only considered when the std
feature is enabled, which it is by
default.)
result_cache: fn() -> Box<dyn ResultCache>
A function to create new result caches.
The default is to do no caching. The easiest way to enable caching is
to set this field to basic_result_cache
(though that is currently
only available with the std
feature).
This is useful for strategies which have a tendency to produce duplicate values, or for tests where shrinking can take a very long time due to exploring the same output multiple times.
When caching is enabled, generated values themselves are not stored, so this does not pose a risk of memory exhaustion for large test inputs unless using extraordinarily large test case counts.
Caching incurs its own overhead, and may very well make your test run more slowly.
verbose: u32
std
only.Set to non-zero values to cause proptest to emit human-targeted messages to stderr as it runs.
Greater values cause greater amounts of logs to be emitted. The exact meaning of certain levels other than 0 is subject to change.
- 0: No extra output.
- 1: Log test failure messages. In state machine tests, this level is used to print transitions.
- 2: Trace low-level details.
This is only available with the std
feature (enabled by default)
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. (The variable is only considered
when the std
feature is enabled, which it is by default.)
rng_algorithm: RngAlgorithm
The RNG algorithm to use when not using a user-provided RNG.
The default is RngAlgorithm::default()
, which can be overridden by
setting the PROPTEST_RNG_ALGORITHM
environment variable to one of the following:
xs
—RngAlgorithm::XorShift
cc
—RngAlgorithm::ChaCha
(The variable is only considered when the std
feature is enabled,
which it is by default.)
Implementations§
§impl Config
impl Config
pub fn with_cases(cases: u32) -> Config
pub fn with_cases(cases: u32) -> Config
Constructs a Config
only differing from the default()
in the
number of test cases required to pass the test successfully.
This is simply a more concise alternative to using field-record update syntax:
assert_eq!(
Config::with_cases(42),
Config { cases: 42, .. Config::default() }
);
pub fn with_source_file(source_file: &'static str) -> Config
pub fn with_source_file(source_file: &'static str) -> Config
Constructs a Config
only differing from the default()
in the
source_file of the present test.
This is simply a more concise alternative to using field-record update syntax:
assert_eq!(
Config::with_source_file("computer/question"),
Config { source_file: Some("computer/question"), .. Config::default() }
);
pub fn clone_with_source_file(&self, source_file: &'static str) -> Config
pub fn clone_with_source_file(&self, source_file: &'static str) -> Config
Constructs a Config
only differing from the provided Config instance, self
,
in the source_file of the present test.
This is simply a more concise alternative to using field-record update syntax:
let a = Config::with_source_file("computer/question");
let b = a.clone_with_source_file("answer/42");
assert_eq!(
a,
Config { source_file: Some("computer/question"), .. Config::default() }
);
assert_eq!(
b,
Config { source_file: Some("answer/42"), .. Config::default() }
);
pub fn fork(&self) -> bool
pub fn fork(&self) -> bool
Return whether this configuration implies forking.
This method exists even if the “fork” feature is disabled, in which case it simply returns false.
pub fn timeout(&self) -> u32
Available on crate feature timeout
only.
pub fn timeout(&self) -> u32
timeout
only.Returns the configured timeout.
This method exists even if the “timeout” feature is disabled, in which case it simply returns 0.
pub fn max_shrink_iters(&self) -> u32
pub fn max_shrink_iters(&self) -> u32
Returns the configured limit on shrinking iterations.
This takes into account the special “automatic” behaviour.
Trait Implementations§
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl !RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl !UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute
] value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
[Quirk
] value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition
] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.§impl<T> TryConv for T
impl<T> TryConv for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 104 bytes