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>
}
// 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));
}