diff options
Diffstat (limited to 'vendor/proptest/src/test_runner')
-rw-r--r-- | vendor/proptest/src/test_runner/config.rs | 3 | ||||
-rw-r--r-- | vendor/proptest/src/test_runner/failure_persistence/file.rs | 19 | ||||
-rw-r--r-- | vendor/proptest/src/test_runner/rng.rs | 19 | ||||
-rw-r--r-- | vendor/proptest/src/test_runner/runner.rs | 22 |
4 files changed, 32 insertions, 31 deletions
diff --git a/vendor/proptest/src/test_runner/config.rs b/vendor/proptest/src/test_runner/config.rs index 04940abc4..232de951b 100644 --- a/vendor/proptest/src/test_runner/config.rs +++ b/vendor/proptest/src/test_runner/config.rs @@ -356,7 +356,8 @@ pub struct Config { /// meaning of certain levels other than 0 is subject to change. /// /// - 0: No extra output. - /// - 1: Log test failure messages. + /// - 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) diff --git a/vendor/proptest/src/test_runner/failure_persistence/file.rs b/vendor/proptest/src/test_runner/failure_persistence/file.rs index 61d7dcf6a..21799adb2 100644 --- a/vendor/proptest/src/test_runner/failure_persistence/file.rs +++ b/vendor/proptest/src/test_runner/failure_persistence/file.rs @@ -39,12 +39,11 @@ pub enum FileFailurePersistence { /// `Direct("NUL")` on Windows (though it is internally handled by simply /// not doing any I/O). Off, - /// The path given to `TestRunner::set_source_file()` is parsed. The path - /// is traversed up the directory tree until a directory containing a file - /// named `lib.rs` or `main.rs` is found. A sibling to that directory with - /// the name given by the string in this configuration is created, and a - /// file with the same name and path relative to the source directory, but - /// with the extension changed to `.txt`, is used. + /// The path of the source file under test is traversed up the directory tree + /// until a directory containing a file named `lib.rs` or `main.rs` is found. + /// A sibling to that directory with the name given by the string in this + /// configuration is created, and a file with the same name and path relative + /// to the source directory, but with the extension changed to `.txt`, is used. /// /// For example, given a source path of /// `/home/jsmith/code/project/src/foo/bar.rs` and a configuration of @@ -58,9 +57,9 @@ pub enum FileFailurePersistence { /// If no source file has been configured, a warning is printed and this /// behaves like `Off`. SourceParallel(&'static str), - /// The path given to `TestRunner::set_source_file()` is parsed. The - /// extension of the path is changed to the string given in this - /// configuration, and that filename is used. + /// Failures are persisted in a file with the same path as the source file + /// under test, but the extension is changed to the string given in this + /// configuration. /// /// For example, given a source path of /// `/home/jsmith/code/project/src/foo/bar.rs` and a configuration of @@ -151,7 +150,7 @@ impl FailurePersistence for FileFailurePersistence { path.display(), e ); - } else if is_new { + } else { eprintln!( "proptest: Saving this and future failures in {}\n\ proptest: If this test was run on a CI system, you may \ diff --git a/vendor/proptest/src/test_runner/rng.rs b/vendor/proptest/src/test_runner/rng.rs index 78c8d7a75..31dd3a354 100644 --- a/vendor/proptest/src/test_runner/rng.rs +++ b/vendor/proptest/src/test_runner/rng.rs @@ -9,9 +9,8 @@ use crate::std_facade::{Arc, String, ToOwned, Vec}; use core::result::Result; -use core::{fmt, str, u8}; +use core::{fmt, str, u8, convert::TryInto}; -use byteorder::{ByteOrder, LittleEndian}; use rand::{self, Rng, RngCore, SeedableRng}; use rand_chacha::ChaChaRng; use rand_xorshift::XorShiftRng; @@ -137,7 +136,7 @@ impl RngCore for TestRng { &mut TestRngImpl::PassThrough { .. } => { let mut buf = [0; 4]; self.fill_bytes(&mut buf[..]); - LittleEndian::read_u32(&buf[..]) + u32::from_le_bytes(buf) } &mut TestRngImpl::Recorder { @@ -160,7 +159,7 @@ impl RngCore for TestRng { &mut TestRngImpl::PassThrough { .. } => { let mut buf = [0; 8]; self.fill_bytes(&mut buf[..]); - LittleEndian::read_u64(&buf[..]) + u64::from_le_bytes(buf) } &mut TestRngImpl::Recorder { @@ -302,7 +301,9 @@ impl Seed { } let mut seed = [0u8; 16]; - LittleEndian::write_u32_into(&dwords[..], &mut seed[..]); + for (chunk, dword) in seed.chunks_mut(4).zip(dwords) { + chunk.copy_from_slice(&dword.to_le_bytes()); + } Some(Seed::XorShift(seed)) } @@ -354,8 +355,12 @@ impl Seed { match *self { Seed::XorShift(ref seed) => { - let mut dwords = [0u32; 4]; - LittleEndian::read_u32_into(seed, &mut dwords[..]); + let dwords = [ + u32::from_le_bytes(seed[0..4].try_into().unwrap()), + u32::from_le_bytes(seed[4..8].try_into().unwrap()), + u32::from_le_bytes(seed[8..12].try_into().unwrap()), + u32::from_le_bytes(seed[12..16].try_into().unwrap()), + ]; format!( "{} {} {} {} {}", RngAlgorithm::XorShift.persistence_key(), diff --git a/vendor/proptest/src/test_runner/runner.rs b/vendor/proptest/src/test_runner/runner.rs index ce540499e..27d0ddf82 100644 --- a/vendor/proptest/src/test_runner/runner.rs +++ b/vendor/proptest/src/test_runner/runner.rs @@ -39,7 +39,9 @@ use crate::test_runner::rng::TestRng; const ENV_FORK_FILE: &'static str = "_PROPTEST_FORKFILE"; const ALWAYS: u32 = 0; -const SHOW_FALURES: u32 = 1; +/// Verbose level 1 to show failures. In state machine tests this level is used +/// to print transitions. +pub const INFO_LOG: u32 = 1; const TRACE: u32 = 2; #[cfg(feature = "std")] @@ -279,18 +281,12 @@ where match result { Ok(()) => verbose_message!(runner, TRACE, "Test case passed"), - Err(TestCaseError::Reject(ref reason)) => verbose_message!( - runner, - SHOW_FALURES, - "Test case rejected: {}", - reason - ), - Err(TestCaseError::Fail(ref reason)) => verbose_message!( - runner, - SHOW_FALURES, - "Test case failed: {}", - reason - ), + Err(TestCaseError::Reject(ref reason)) => { + verbose_message!(runner, INFO_LOG, "Test case rejected: {}", reason) + } + Err(TestCaseError::Fail(ref reason)) => { + verbose_message!(runner, INFO_LOG, "Test case failed: {}", reason) + } } result.map(|_| { |