From d0c8b29ec66e1ddf9a4f722969794f8ebc6f07e7 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 29 Jan 2022 12:18:27 -0500 Subject: [PATCH] fs: Add a regression test for #93384 --- library/std/src/fs/tests.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index a62c01ef29b27..16b8bf68242ef 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -1504,3 +1504,19 @@ fn create_dir_long_paths() { let path = Path::new(""); assert_eq!(path.canonicalize().unwrap_err().kind(), crate::io::ErrorKind::NotFound); } + +/// Ensure ReadDir works on large directories. +/// Regression test for https://github.com/rust-lang/rust/issues/93384. +#[test] +fn read_large_dir() { + let tmpdir = tmpdir(); + + let count = 32 * 1024; + for i in 0..count { + check!(fs::File::create(tmpdir.join(&i.to_string()))); + } + + for entry in fs::read_dir(tmpdir.path()).unwrap() { + entry.unwrap(); + } +}