Skip to content

Commit 9fb7c5a

Browse files
committed
fs/tests: Fail fast on duplicate errors rather than looping indefinitely
1 parent 1550a25 commit 9fb7c5a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/std/src/fs/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,6 @@ fn test_read_dir_infinite_loop() {
15921592
// Skip the test if we can't open the directory in the first place
15931593
let Ok(dir) = fs::read_dir(path) else { return };
15941594

1595-
// Iterate through the directory
1596-
for _ in dir {}
1595+
// Check for duplicate errors
1596+
assert!(dir.filter(|e| e.is_err()).take(2).count() < 2);
15971597
}

0 commit comments

Comments
 (0)