]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/fs/tests.rs
Rollup merge of #99581 - nnethercote:improve-derive-packed-errors, r=estebank
[rust.git] / library / std / src / fs / tests.rs
index e1ebb1a690b0aed35717803cb772e42105370860..b8959316de170e568de3fc7a366ed478158855dc 100644 (file)
@@ -1535,13 +1535,19 @@ fn read_large_dir() {
     }
 }
 
-#[test]
+/// Test the fallback for getting the metadata of files like hiberfil.sys that
+/// Windows holds a special lock on, preventing normal means of querying
+/// metadata. See #96980.
+///
+/// Note this fails in CI because `hiberfil.sys` does not actually exist there.
+/// Therefore it's marked as ignored.
+#[test]
+#[ignore]
 #[cfg(windows)]
 fn hiberfil_sys() {
-    // Get the system drive, which is usually `C:`.
-    let mut hiberfil = crate::env::var("SystemDrive").unwrap();
-    hiberfil.push_str(r"\hiberfil.sys");
-
-    fs::metadata(&hiberfil).unwrap();
-    fs::symlink_metadata(&hiberfil).unwrap();
+    let hiberfil = Path::new(r"C:\hiberfil.sys");
+    assert_eq!(true, hiberfil.try_exists().unwrap());
+    fs::symlink_metadata(hiberfil).unwrap();
+    fs::metadata(hiberfil).unwrap();
+    assert_eq!(true, hiberfil.exists());
 }