From 72b0ac09e0248b99dff9c24f80e4b5f9850a0a29 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 5 Jul 2018 17:45:22 +0000 Subject: [PATCH 1/3] Update rand requirement to 0.5 Updates the requirements on [rand](/~https://github.com/rust-lang-nursery/rand) to permit the latest version. - [Release notes](/~https://github.com/rust-lang-nursery/rand/releases) - [Changelog](/~https://github.com/rust-lang-nursery/rand/blob/master/CHANGELOG.md) - [Commits](/~https://github.com/rust-lang-nursery/rand/commits/0.5.3) Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3d89a9359..d8f3b15bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ futures = { version = "0.1", optional = true } miniz_oxide_c_api = { version = "0.1", optional = true, features = ["no_c_export"]} [dev-dependencies] -rand = "0.4" +rand = "0.5" quickcheck = { version = "0.6", default-features = false } tokio-core = "0.1" From 1e20fa9ac1e18a81ed2d3e87913e81759d696873 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 5 Jul 2018 11:21:54 -0700 Subject: [PATCH 2/3] Fix rand 0.5 compat --- src/deflate/mod.rs | 29 +++++++---------------------- src/gz/mod.rs | 7 ++----- src/lib.rs | 8 ++++++++ src/zlib/mod.rs | 19 +++++-------------- 4 files changed, 22 insertions(+), 41 deletions(-) diff --git a/src/deflate/mod.rs b/src/deflate/mod.rs index b9e46ec0a..9ea81dcc6 100644 --- a/src/deflate/mod.rs +++ b/src/deflate/mod.rs @@ -15,7 +15,7 @@ mod tests { fn roundtrip() { let mut real = Vec::new(); let mut w = write::DeflateEncoder::new(Vec::new(), Compression::default()); - let v = thread_rng().gen_iter::().take(1024).collect::>(); + let v = ::random_bytes().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; real.extend(to_write.iter().map(|x| *x)); @@ -44,7 +44,7 @@ mod tests { fn total_in() { let mut real = Vec::new(); let mut w = write::DeflateEncoder::new(Vec::new(), Compression::default()); - let v = thread_rng().gen_iter::().take(1024).collect::>(); + let v = ::random_bytes().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; real.extend(to_write.iter().map(|x| *x)); @@ -67,10 +67,7 @@ mod tests { #[test] fn roundtrip2() { - let v = thread_rng() - .gen_iter::() - .take(1024 * 1024) - .collect::>(); + let v = ::random_bytes().take(1024 * 1024).collect::>(); let mut r = read::DeflateDecoder::new(read::DeflateEncoder::new(&v[..], Compression::default())); let mut ret = Vec::new(); @@ -80,10 +77,7 @@ mod tests { #[test] fn roundtrip3() { - let v = thread_rng() - .gen_iter::() - .take(1024 * 1024) - .collect::>(); + let v = ::random_bytes().take(1024 * 1024).collect::>(); let mut w = write::DeflateEncoder::new( write::DeflateDecoder::new(Vec::new()), Compression::default(), @@ -95,10 +89,7 @@ mod tests { #[test] fn reset_writer() { - let v = thread_rng() - .gen_iter::() - .take(1024 * 1024) - .collect::>(); + let v = ::random_bytes().take(1024 * 1024).collect::>(); let mut w = write::DeflateEncoder::new(Vec::new(), Compression::default()); w.write_all(&v).unwrap(); let a = w.reset(Vec::new()).unwrap(); @@ -113,10 +104,7 @@ mod tests { #[test] fn reset_reader() { - let v = thread_rng() - .gen_iter::() - .take(1024 * 1024) - .collect::>(); + let v = ::random_bytes().take(1024 * 1024).collect::>(); let (mut a, mut b, mut c) = (Vec::new(), Vec::new(), Vec::new()); let mut r = read::DeflateEncoder::new(&v[..], Compression::default()); r.read_to_end(&mut a).unwrap(); @@ -130,10 +118,7 @@ mod tests { #[test] fn reset_decoder() { - let v = thread_rng() - .gen_iter::() - .take(1024 * 1024) - .collect::>(); + let v = ::random_bytes().take(1024 * 1024).collect::>(); let mut w = write::DeflateEncoder::new(Vec::new(), Compression::default()); w.write_all(&v).unwrap(); let data = w.finish().unwrap(); diff --git a/src/gz/mod.rs b/src/gz/mod.rs index 5dee3218b..5fcbe50d1 100644 --- a/src/gz/mod.rs +++ b/src/gz/mod.rs @@ -285,7 +285,7 @@ mod tests { fn roundtrip_big() { let mut real = Vec::new(); let mut w = write::GzEncoder::new(Vec::new(), Compression::default()); - let v = thread_rng().gen_iter::().take(1024).collect::>(); + let v = ::random_bytes().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; real.extend(to_write.iter().map(|x| *x)); @@ -300,10 +300,7 @@ mod tests { #[test] fn roundtrip_big2() { - let v = thread_rng() - .gen_iter::() - .take(1024 * 1024) - .collect::>(); + let v = ::random_bytes().take(1024 * 1024).collect::>(); let mut r = read::GzDecoder::new(read::GzEncoder::new(&v[..], Compression::default())); let mut res = Vec::new(); r.read_to_end(&mut res).unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 47013e0e1..3e62d0fc2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -202,3 +202,11 @@ impl Default for Compression { Compression(6) } } + +#[cfg(test)] +fn random_bytes() -> impl Iterator { + use std::iter; + use rand::Rng; + + iter::repeat(()).map(|_| rand::thread_rng().gen()) +} diff --git a/src/zlib/mod.rs b/src/zlib/mod.rs index 1606bbf6c..c729df1c2 100644 --- a/src/zlib/mod.rs +++ b/src/zlib/mod.rs @@ -16,7 +16,7 @@ mod tests { fn roundtrip() { let mut real = Vec::new(); let mut w = write::ZlibEncoder::new(Vec::new(), Compression::default()); - let v = thread_rng().gen_iter::().take(1024).collect::>(); + let v = ::random_bytes().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; real.extend(to_write.iter().map(|x| *x)); @@ -45,7 +45,7 @@ mod tests { fn total_in() { let mut real = Vec::new(); let mut w = write::ZlibEncoder::new(Vec::new(), Compression::default()); - let v = thread_rng().gen_iter::().take(1024).collect::>(); + let v = ::random_bytes().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; real.extend(to_write.iter().map(|x| *x)); @@ -68,10 +68,7 @@ mod tests { #[test] fn roundtrip2() { - let v = thread_rng() - .gen_iter::() - .take(1024 * 1024) - .collect::>(); + let v = ::random_bytes().take(1024 * 1024).collect::>(); let mut r = read::ZlibDecoder::new(read::ZlibEncoder::new(&v[..], Compression::default())); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); @@ -80,10 +77,7 @@ mod tests { #[test] fn roundtrip3() { - let v = thread_rng() - .gen_iter::() - .take(1024 * 1024) - .collect::>(); + let v = ::random_bytes().take(1024 * 1024).collect::>(); let mut w = write::ZlibEncoder::new(write::ZlibDecoder::new(Vec::new()), Compression::default()); w.write_all(&v).unwrap(); @@ -93,10 +87,7 @@ mod tests { #[test] fn reset_decoder() { - let v = thread_rng() - .gen_iter::() - .take(1024 * 1024) - .collect::>(); + let v = ::random_bytes().take(1024 * 1024).collect::>(); let mut w = write::ZlibEncoder::new(Vec::new(), Compression::default()); w.write_all(&v).unwrap(); let data = w.finish().unwrap(); From 4615e0dd9e273828ee04d863fef511f8bd6a1a5e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 5 Jul 2018 11:34:58 -0700 Subject: [PATCH 3/3] Remove 1.21.0 from travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 76257cc38..672adbf6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ sudo: false matrix: include: - - rust: 1.21.0 - rust: stable - os: osx - rust: beta