fs/tests: Fail fast on duplicate errors rather than looping indefinitely

This commit is contained in:
Tavian Barnes 2022-12-14 10:01:42 -05:00
parent 1550a2506d
commit 9fb7c5ae5e

View File

@ -1592,6 +1592,6 @@ fn test_read_dir_infinite_loop() {
// Skip the test if we can't open the directory in the first place
let Ok(dir) = fs::read_dir(path) else { return };
// Iterate through the directory
for _ in dir {}
// Check for duplicate errors
assert!(dir.filter(|e| e.is_err()).take(2).count() < 2);
}