Skip to content

Commit 6259028

Browse files
committed
Add test for regression for FileType equality
Cf: #104900
1 parent 7700595 commit 6259028

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

library/std/src/fs/tests.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,3 +1551,19 @@ fn hiberfil_sys() {
15511551
fs::metadata(hiberfil).unwrap();
15521552
assert_eq!(true, hiberfil.exists());
15531553
}
1554+
1555+
/// Test that two different ways of obtaining the FileType give the same result.
1556+
/// Cf. https://github.com/rust-lang/rust/issues/104900
1557+
#[test]
1558+
fn test_eq_direntry_metadata() {
1559+
let tmpdir = tmpdir();
1560+
let file_path = tmpdir.join("file");
1561+
File::create(file_path).unwrap();
1562+
for e in fs::read_dir(tmpdir.path()).unwrap() {
1563+
let e = e.unwrap();
1564+
let p = e.path();
1565+
let ft1 = e.file_type().unwrap();
1566+
let ft2 = p.metadata().unwrap().file_type();
1567+
assert_eq!(ft1, ft2);
1568+
}
1569+
}

0 commit comments

Comments
 (0)