jgiannuzzi commented on code in PR #676:
URL: 
https://github.com/apache/arrow-rs-object-store/pull/676#discussion_r3051845713


##########
src/local.rs:
##########
@@ -1913,4 +1956,16 @@ mod unix_test {
 
         spawned.await.unwrap();
     }
+
+    #[test]
+    fn test_close_file_detects_error() {
+        use std::os::unix::io::AsRawFd;
+
+        let file = tempfile::tempfile().unwrap();
+        let fd = file.as_raw_fd();
+        // Close the fd behind Rust's back so close_file will get EBADF
+        assert_eq!(unsafe { libc::close(fd) }, 0);
+        let err = super::close_file(file).unwrap_err();
+        assert_eq!(err.raw_os_error(), Some(libc::EBADF));
+    }

Review Comment:
   Good point! I've updated the Unix test and added a Windows version of it. 
Sadly I still need to use a raw fd/handle in order to not consume the file and 
be able to close it twice. Thank you Rust for generally preventing misusing 
APIs! (That's not sarcasm 😅)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to