]> git.lizzy.rs Git - rust.git/commitdiff
Fix up stat test in libc-fs-with-isolation
authorMateusz Guzik <mjguzik@gmail.com>
Wed, 11 Jan 2023 17:05:15 +0000 (17:05 +0000)
committerMateusz Guzik <mjguzik@gmail.com>
Wed, 11 Jan 2023 17:09:12 +0000 (17:09 +0000)
The test relied on Error::last_os_error() coming from the stat call on
the passed file, but there is no guarantee this will be the case.

Instead extract errno from the error returned by the routine.

Patch de facto written by joboet.

Co-authored-by: joboet <jonasboettiger@icloud.com>

src/tools/miri/tests/pass-dep/shims/libc-fs-with-isolation.rs

index f1838cf64f7feefbf5d5b0a01f7e8c5e3fe7fd9a..d6d19a3fe8159ccc66ceb1ad7cf44e9ba9da742b 100644 (file)
@@ -22,7 +22,8 @@ fn main() {
     }
 
     // test `stat`
-    assert_eq!(fs::metadata("foo.txt").unwrap_err().kind(), ErrorKind::PermissionDenied);
+    let err = fs::metadata("foo.txt").unwrap_err();
+    assert_eq!(err.kind(), ErrorKind::PermissionDenied);
     // check that it is the right kind of `PermissionDenied`
-    assert_eq!(Error::last_os_error().raw_os_error(), Some(libc::EACCES));
+    assert_eq!(err.raw_os_error(), Some(libc::EACCES));
 }