Skip to content

Commit

Permalink
Check IO errors in test using raw_os_error() instead of kind()
Browse files Browse the repository at this point in the history
std::io::ErrorKind is a `#[non_exhaustive]` enum as more specific
error types are to be added in the future. It was unclear in the
docs until very recently, however, that this is to be done by
re-defining `ErrorKind::Other` errors to new enum variants. Thus,
our tests which check explicitly for `ErrorKind::Other` as a
result of trying to access a directory as a file were incorrect.
Sadly, these generated no meaningful feedback from rustc at all,
except that they're suddenly failing in rustc beta!

After some back-and-forth, it seems rustc is moving forward
breaking existing code in future versions, so we move to the
"correct" check here, which is to check the raw IO error.

See rust-lang/rust#86442 and rust-lang/rust#85746 for more info.
  • Loading branch information
TheBlueMatt committed Aug 2, 2021
1 parent 0fa1865 commit 8a930fb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lightning-persister/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ mod tests {
match write_to_file(path, filename, &test_writeable) {
Err(e) => {
#[cfg(not(target_os = "windows"))]
assert_eq!(e.kind(), io::ErrorKind::Other);
assert_eq!(e.raw_os_error(), Some(libc::EISDIR));
#[cfg(target_os = "windows")]
assert_eq!(e.kind(), io::ErrorKind::PermissionDenied);
}
Expand Down

0 comments on commit 8a930fb

Please sign in to comment.