Skip to content

Commit

Permalink
Auto merge of #1212 - RalfJung:tests, r=RalfJung
Browse files Browse the repository at this point in the history
expand clock and fs tests a bit
  • Loading branch information
bors committed Mar 6, 2020
2 parents c72af45 + fefa8e5 commit e6a0c60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion tests/run-pass/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
6 changes: 5 additions & 1 deletion tests/run-pass/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

0 comments on commit e6a0c60

Please sign in to comment.