Skip to content

Commit

Permalink
fs/tests: Fail fast on duplicate errors rather than looping indefinitely
Browse files Browse the repository at this point in the history
  • Loading branch information
tavianator committed Dec 14, 2022
1 parent 1550a25 commit 9fb7c5a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 9fb7c5a

Please sign in to comment.