about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-01-29 12:18:27 -0500
committerTavian Barnes <tavianator@tavianator.com>2022-01-29 16:37:21 -0500
commitd0c8b29ec66e1ddf9a4f722969794f8ebc6f07e7 (patch)
tree1f14fc4454d7a667739fa0e1a8b1086fa2a9cc2e
parentf8f4c4052715994338757244fcaacc093f3c6808 (diff)
downloadrust-d0c8b29ec66e1ddf9a4f722969794f8ebc6f07e7.tar.gz
rust-d0c8b29ec66e1ddf9a4f722969794f8ebc6f07e7.zip
fs: Add a regression test for #93384
-rw-r--r--library/std/src/fs/tests.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs
index a62c01ef29b..16b8bf68242 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();
+    }
+}