mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 14:10:03 +03:00
expand clock and fs tests a bit
This commit is contained in:
@@ -4,5 +4,11 @@
|
||||
use std::time::SystemTime;
|
||||
|
||||
fn main() {
|
||||
let _now = SystemTime::now();
|
||||
let now1 = SystemTime::now();
|
||||
|
||||
// Do some work to make time pass.
|
||||
for _ in 0..10 { drop(vec![42]); }
|
||||
|
||||
let now2 = SystemTime::now();
|
||||
assert!(now2 > now1);
|
||||
}
|
||||
|
||||
@@ -215,9 +215,13 @@ fn test_directory() {
|
||||
// Clean up the files in the directory
|
||||
remove_file(&path_1).unwrap();
|
||||
remove_file(&path_2).unwrap();
|
||||
// Now there should be nothing left in the directory.
|
||||
let dir_iter = read_dir(&dir_path).unwrap();
|
||||
let file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::<Vec<_>>();
|
||||
assert!(file_names.is_empty());
|
||||
|
||||
// Deleting the directory should succeed.
|
||||
remove_dir(&dir_path).unwrap();
|
||||
// Reading the metadata of a non-existent file should fail with a "not found" error.
|
||||
// Reading the metadata of a non-existent directory should fail with a "not found" error.
|
||||
assert_eq!(ErrorKind::NotFound, check_metadata(&[], &dir_path).unwrap_err().kind());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user