Skip to content

Commit 5d16163

Browse files
committed
deps: drop quickcheck and rand
These weren't carrying their weight. Depending on rand is super annoying, so just stop doing it. In particular, we can bring back the minimal version check.
1 parent 526d70b commit 5d16163

File tree

4 files changed

+14
-140
lines changed

4 files changed

+14
-140
lines changed

Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,4 @@ features = ["std", "winnt"]
3030
version = "0.1.1"
3131

3232
[dev-dependencies]
33-
quickcheck = { version = "0.8.2", default-features = false }
34-
rand = "0.6.5"
3533
doc-comment = "0.3"

ci/script.sh

+6
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ fi
1414
cargo build --verbose --all
1515
cargo doc --verbose
1616
cargo test --verbose
17+
18+
if [ "$TRAVIS_RUST_VERSION" = nightly ]; then
19+
cargo +nightly generate-lockfile -Z minimal-versions
20+
cargo build --verbose
21+
cargo test --verbose
22+
fi

src/lib.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,13 @@ for entry in walker.filter_entry(|e| !is_hidden(e)) {
107107
#![allow(bare_trait_objects)]
108108

109109
#[cfg(test)]
110-
extern crate quickcheck;
111-
#[cfg(test)]
112-
extern crate rand;
110+
#[macro_use]
111+
extern crate doc_comment;
113112
extern crate same_file;
114113
#[cfg(windows)]
115114
extern crate winapi;
116115
#[cfg(windows)]
117116
extern crate winapi_util;
118-
#[cfg(test)]
119-
#[macro_use]
120-
extern crate doc_comment;
121117

122118
#[cfg(test)]
123119
doctest!("../README.md");

src/tests.rs

+6-132
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ use std::io;
77
use std::path::{Path, PathBuf};
88
use std::collections::HashMap;
99

10-
use quickcheck::{Arbitrary, Gen, QuickCheck, StdGen};
11-
use rand::{self, Rng, RngCore};
12-
1310
use super::{DirEntry, WalkDir, IntoIter, Error, ErrorInner};
1411

1512
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
@@ -95,14 +92,6 @@ impl Tree {
9592
.unwrap_or_default()))
9693
}
9794

98-
fn name(&self) -> &Path {
99-
match *self {
100-
Tree::Dir(ref pb, _) => pb,
101-
Tree::File(ref pb) => pb,
102-
Tree::Symlink { ref dst, .. } => dst,
103-
}
104-
}
105-
10695
fn unwrap_singleton(self) -> Tree {
10796
match self {
10897
Tree::File(_) | Tree::Symlink { .. } => {
@@ -170,97 +159,6 @@ impl Tree {
170159
}
171160
}
172161
}
173-
174-
fn dedup(&self) -> Tree {
175-
match *self {
176-
Tree::Symlink { ref src, ref dst, dir } => {
177-
Tree::Symlink { src: src.clone(), dst: dst.clone(), dir: dir }
178-
}
179-
Tree::File(ref p) => {
180-
Tree::File(p.clone())
181-
}
182-
Tree::Dir(ref p, ref cs) => {
183-
let mut nodupes: Vec<Tree> = vec![];
184-
for (i, c1) in cs.iter().enumerate() {
185-
if !cs[i+1..].iter().any(|c2| c1.name() == c2.name())
186-
&& !nodupes.iter().any(|c2| c1.name() == c2.name()) {
187-
nodupes.push(c1.dedup());
188-
}
189-
}
190-
Tree::Dir(p.clone(), nodupes)
191-
}
192-
}
193-
}
194-
195-
fn gen<G: Gen>(g: &mut G, depth: usize) -> Tree {
196-
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
197-
struct NonEmptyAscii(String);
198-
199-
impl Arbitrary for NonEmptyAscii {
200-
fn arbitrary<G: Gen>(g: &mut G) -> NonEmptyAscii {
201-
use std::char::from_u32;
202-
let upper_bound = g.size();
203-
// We start with a lower bound of `4` to avoid
204-
// generating the special file name `con` on Windows,
205-
// because such files cannot exist...
206-
let size = g.gen_range(4, upper_bound);
207-
NonEmptyAscii((0..size)
208-
.map(|_| from_u32(g.gen_range(97, 123)).unwrap())
209-
.collect())
210-
}
211-
212-
fn shrink(&self) -> Box<Iterator<Item=NonEmptyAscii>> {
213-
let mut smaller = vec![];
214-
for i in 1..self.0.len() {
215-
let s: String = self.0.chars().skip(i).collect();
216-
smaller.push(NonEmptyAscii(s));
217-
}
218-
Box::new(smaller.into_iter())
219-
}
220-
}
221-
222-
let name = pb(NonEmptyAscii::arbitrary(g).0);
223-
if depth == 0 {
224-
Tree::File(name)
225-
} else {
226-
let children: Vec<Tree> =
227-
(0..g.gen_range(0, 5))
228-
.map(|_| Tree::gen(g, depth-1))
229-
.collect();
230-
Tree::Dir(name, children)
231-
}
232-
}
233-
}
234-
235-
impl Arbitrary for Tree {
236-
fn arbitrary<G: Gen>(g: &mut G) -> Tree {
237-
let depth = g.gen_range(0, 5);
238-
Tree::gen(g, depth).dedup()
239-
}
240-
241-
fn shrink(&self) -> Box<Iterator<Item=Tree>> {
242-
let trees: Box<Iterator<Item=Tree>> = match *self {
243-
Tree::Symlink { .. } => unimplemented!(),
244-
Tree::File(ref path) => {
245-
let s = path.to_string_lossy().into_owned();
246-
Box::new(s.shrink().map(|s| Tree::File(pb(s))))
247-
}
248-
Tree::Dir(ref path, ref children) => {
249-
let s = path.to_string_lossy().into_owned();
250-
if children.is_empty() {
251-
Box::new(s.shrink().map(|s| Tree::Dir(pb(s), vec![])))
252-
} else if children.len() == 1 {
253-
let c = &children[0];
254-
Box::new(Some(c.clone()).into_iter().chain(c.shrink()))
255-
} else {
256-
Box::new(children
257-
.shrink()
258-
.map(move |cs| Tree::Dir(pb(s.clone()), cs)))
259-
}
260-
}
261-
};
262-
Box::new(trees.map(|t| t.dedup()))
263-
}
264162
}
265163

266164
#[derive(Debug)]
@@ -328,9 +226,13 @@ impl Drop for TempDir {
328226
}
329227

330228
fn tmpdir() -> TempDir {
229+
use std::sync::atomic::{AtomicUsize, Ordering};
230+
231+
static COUNTER: AtomicUsize = AtomicUsize::new(0);
232+
331233
let p = env::temp_dir();
332-
let mut r = rand::thread_rng();
333-
let ret = p.join(&format!("rust-{}", r.next_u32()));
234+
let idx = COUNTER.fetch_add(1, Ordering::SeqCst);
235+
let ret = p.join(&format!("rust-{}", idx));
334236
fs::create_dir(&ret).unwrap();
335237
TempDir(ret)
336238
}
@@ -782,34 +684,6 @@ fn walk_dir_filter() {
782684
assert_eq!(got, vec!["bar", "faz", "foo"]);
783685
}
784686

785-
#[test]
786-
fn qc_roundtrip() {
787-
fn p(exp: Tree) -> bool {
788-
let (_tmp, got) = dir_setup(&exp);
789-
exp.canonical() == got.canonical()
790-
}
791-
QuickCheck::new()
792-
.gen(StdGen::new(rand::thread_rng(), 15))
793-
.tests(1_000)
794-
.max_tests(10_000)
795-
.quickcheck(p as fn(Tree) -> bool);
796-
}
797-
798-
// Same as `qc_roundtrip`, but makes sure `follow_links` doesn't change
799-
// the behavior of walking a directory *without* symlinks.
800-
#[test]
801-
fn qc_roundtrip_no_symlinks_with_follow() {
802-
fn p(exp: Tree) -> bool {
803-
let (_tmp, got) = dir_setup_with(&exp, |wd| wd.follow_links(true));
804-
exp.canonical() == got.canonical()
805-
}
806-
QuickCheck::new()
807-
.gen(StdGen::new(rand::thread_rng(), 15))
808-
.tests(1_000)
809-
.max_tests(10_000)
810-
.quickcheck(p as fn(Tree) -> bool);
811-
}
812-
813687
#[test]
814688
fn walk_dir_sort() {
815689
let exp = td("foo", vec![

0 commit comments

Comments
 (0)