Skip to content

Commit

Permalink
note that PROPTEST_CASES and other env var requires the std feature (#…
Browse files Browse the repository at this point in the history
…262)

* note that PROPTEST_CASES env var requires the std feature

* note that PROPTEST_CASES and other env vars require the std feature

* note that PROPTEST_CASES and other env vars require the std feature
  • Loading branch information
RalfJung committed Jan 7, 2023
1 parent a6b09de commit 7a94e16
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
3 changes: 2 additions & 1 deletion book/src/proptest/tutorial/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ and want to run more or fewer, there are a few ways to do this.

The first way is to set the environment-variable `PROPTEST_CASES` to a
value that can be successfully parsed as a `u32`. The value you set to this
variable is now the new default.
variable is now the new default. (This only applies when the `std` feature of
proptest is enabled, which it is by default.)

Another way is to use `#![proptest_config(expr)]` inside `proptest!` where
`expr : Config`. To only change the number of test cases, you can simply
Expand Down
28 changes: 21 additions & 7 deletions proptest/src/test_runner/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,29 +182,35 @@ pub struct Config {
/// This does not include implicitly-replayed persisted failing cases.
///
/// The default is 256, which can be overridden by setting the
/// `PROPTEST_CASES` environment variable.
/// `PROPTEST_CASES` environment variable. (The variable is only considered
/// when the `std` feature is enabled, which it is by default.)
pub cases: 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.
/// `PROPTEST_MAX_LOCAL_REJECTS` environment variable. (The variable is only
/// considered when the `std` feature is enabled, which it is by default.)
pub max_local_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.
/// `PROPTEST_MAX_GLOBAL_REJECTS` environment variable. (The variable is
/// only considered when the `std` feature is enabled, which it is by
/// default.)
pub max_global_rejects: 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.
/// `PROPTEST_MAX_FLAT_MAP_REGENS` environment variable. (The variable is
/// only considered when the `std` feature is enabled, which it is by
/// default.)
pub max_flat_map_regens: u32,

/// Indicates whether and how to persist failed test results.
Expand Down Expand Up @@ -271,7 +277,9 @@ pub struct Config {
/// aborted.
///
/// The default is `0` (i.e., no timeout), which can be overridden by
/// setting the `PROPTEST_TIMEOUT` environment variable.
/// setting the `PROPTEST_TIMEOUT` environment variable. (The variable is
/// only considered when the `std` feature is enabled, which it is by
/// default.)
#[cfg(feature = "timeout")]
pub timeout: u32,

Expand All @@ -284,7 +292,9 @@ pub struct Config {
/// (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 `PROPTEST_MAX_SHRINK_TIME` environment variable. (The variable is
/// only considered when the `std` feature is enabled, which it is by
/// default.)
#[cfg(feature = "std")]
pub max_shrink_time: u32,

Expand All @@ -300,7 +310,8 @@ pub struct Config {
/// 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.
/// `PROPTEST_MAX_SHRINK_ITERS` environment variable. (The variable is only
/// considered when the `std` feature is enabled, which it is by default.)
pub max_shrink_iters: u32,

/// A function to create new result caches.
Expand Down Expand Up @@ -346,6 +357,9 @@ pub struct Config {
///
/// - `xs` — `RngAlgorithm::XorShift`
/// - `cc` — `RngAlgorithm::ChaCha`
///
/// (The variable is only considered when the `std` feature is enabled,
/// which it is by default.)
pub rng_algorithm: RngAlgorithm,

// Needs to be public so FRU syntax can be used.
Expand Down

0 comments on commit 7a94e16

Please sign in to comment.