From 341212acd67d2409265333f2c598d446525b5468 Mon Sep 17 00:00:00 2001 From: David Cook Date: Sat, 8 Feb 2020 22:27:26 -0600 Subject: [PATCH] Rewrite fs tests --- tests/run-pass/fs.rs | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/tests/run-pass/fs.rs b/tests/run-pass/fs.rs index 59eb4e01437..b938fceb8d0 100644 --- a/tests/run-pass/fs.rs +++ b/tests/run-pass/fs.rs @@ -206,23 +206,10 @@ fn test_directory() { let path_2 = dir_path.join("test_file_2"); drop(File::create(&path_2).unwrap()); // Test that the files are present inside the directory - let mut dir_iter = read_dir(&dir_path).unwrap(); - let first_dir_entry = dir_iter.next().unwrap().unwrap(); - let second_dir_entry = dir_iter.next().unwrap().unwrap(); - assert!( - first_dir_entry.file_name() == "test_file_1" || - first_dir_entry.file_name() == "test_file_2", - "File name was {:?} instead of test_file_1 or test_file_2", - first_dir_entry.file_name(), - ); - assert!( - second_dir_entry.file_name() == "test_file_1" || - second_dir_entry.file_name() == "test_file_2", - "File name was {:?} instead of test_file_1 or test_file_2", - second_dir_entry.file_name(), - ); - assert!(dir_iter.next().is_none()); - drop(dir_iter); + let dir_iter = read_dir(&dir_path).unwrap(); + let mut file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::>(); + file_names.sort_unstable(); + assert_eq!(file_names, vec!["test_file_1", "test_file_2"]); // Clean up the files in the directory remove_file(&path_1).unwrap(); remove_file(&path_2).unwrap(); -- 2.44.0