Skip to content

Commit 29cd8dd

Browse files
committed
Move file created times test into fs_additional
1 parent 6112c88 commit 29cd8dd

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

tests/fs_additional.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,3 +872,37 @@ fn reopen_fd() {
872872
let tmpdir2 = check!(cap_std::fs::Dir::reopen_dir(&tmpdir.as_filelike()));
873873
assert!(tmpdir2.exists("subdir"));
874874
}
875+
876+
#[test]
877+
fn metadata_created() {
878+
let tmpdir = tmpdir();
879+
check!(tmpdir.create_dir("dir"));
880+
let dir = check!(tmpdir.open_dir("dir"));
881+
let file = check!(dir.create("file"));
882+
883+
let cap_std_dir = check!(dir.dir_metadata());
884+
let cap_std_file = check!(file.metadata());
885+
let cap_std_dir_entry = {
886+
let mut entries = check!(dir.entries());
887+
let entry = check!(entries.next().unwrap());
888+
assert_eq!(entry.file_name(), "file");
889+
assert!(entries.next().is_none(), "unexpected dir entry");
890+
check!(entry.metadata())
891+
};
892+
893+
let std_dir = check!(dir.into_std_file().metadata());
894+
let std_file = check!(file.into_std().metadata());
895+
896+
// If the standard library supports file creation times, then cap-std
897+
// should too.
898+
if let Ok(expected) = std_dir.created() {
899+
println!("std::fs supports file created times");
900+
assert_eq!(expected, check!(cap_std_dir.created()).into_std());
901+
} else {
902+
println!("std::fs doesn't support file created times");
903+
}
904+
if let Ok(expected) = std_file.created() {
905+
assert_eq!(expected, check!(cap_std_file.created()).into_std());
906+
assert_eq!(expected, check!(cap_std_dir_entry.created()).into_std());
907+
}
908+
}

tests/metadata-ext.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -83,37 +83,3 @@ fn test_metadata_ext() {
8383
);
8484
}
8585
}
86-
87-
#[test]
88-
fn test_metadata_ext_created() {
89-
let tmpdir = tmpdir();
90-
check!(tmpdir.create_dir("dir"));
91-
let dir = check!(tmpdir.open_dir("dir"));
92-
let file = check!(dir.create("file"));
93-
94-
let cap_std_dir = check!(dir.dir_metadata());
95-
let cap_std_file = check!(file.metadata());
96-
let cap_std_dir_entry = {
97-
let mut entries = check!(dir.entries());
98-
let entry = check!(entries.next().unwrap());
99-
assert_eq!(entry.file_name(), "file");
100-
assert!(entries.next().is_none(), "unexpected dir entry");
101-
check!(entry.metadata())
102-
};
103-
104-
let std_dir = check!(dir.into_std_file().metadata());
105-
let std_file = check!(file.into_std().metadata());
106-
107-
// If the standard library supports file creation times, then cap-std
108-
// should too.
109-
if let Ok(expected) = std_dir.created() {
110-
println!("std::fs supports file created times");
111-
assert_eq!(expected, check!(cap_std_dir.created()).into_std());
112-
} else {
113-
println!("std::fs doesn't support file created times");
114-
}
115-
if let Ok(expected) = std_file.created() {
116-
assert_eq!(expected, check!(cap_std_file.created()).into_std());
117-
assert_eq!(expected, check!(cap_std_dir_entry.created()).into_std());
118-
}
119-
}

0 commit comments

Comments
 (0)