Skip to content

Commit

Permalink
test OpenOptions custom_flags fn on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
brodycj committed Feb 22, 2023
1 parent 47f4e2e commit 73eafdd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion tokio/src/fs/open_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,6 @@ feature! {
/// [`CreateFile`]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea
/// [`CreateFile2`]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfile2
pub fn custom_flags(&mut self, flags: u32) -> &mut OpenOptions {
assert!(std::env::var("XXX_KEEP_UNTESTED_XXX").is_ok());
self.as_inner_mut().custom_flags(flags);
self
}
Expand Down
12 changes: 12 additions & 0 deletions tokio/tests/fs_open_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::io::Write;
use tempfile::NamedTempFile;
use tokio::fs::OpenOptions;
use tokio::io::AsyncReadExt;
use windows_sys::Win32::Storage::FileSystem;

const HELLO: &[u8] = b"hello world...";

Expand Down Expand Up @@ -78,3 +79,14 @@ async fn open_options_custom_flags_bsd_family() {
.contains("custom_flags: 256")
);
}

#[tokio::test]
#[cfg(windows)]
async fn open_options_custom_flags_windows() {
// TEST HACK: use Debug output to check the stored data
assert!(format!(
"{:?}",
OpenOptions::new().custom_flags(FileSystem::FILE_FLAG_DELETE_ON_CLOSE)
)
.contains("custom_flags: 67108864,"));
}

0 comments on commit 73eafdd

Please sign in to comment.