Skip to content

Commit b88cbed

Browse files
committed
Make sure to sync on file-io.rs tokio test
Tokio `AsyncWriteExt::write` doesn't actually ensure that the contents have written, it just *starts* the write operation. To ensure that the file has actually been written, we need to `sync_all` first.
1 parent 4b94f67 commit b88cbed

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/tools/miri/tests/pass-dep/tokio/file-io.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ async fn test_create_and_write() -> io::Result<()> {
2121

2222
// Write 10 bytes to the file.
2323
file.write_all(b"some bytes").await?;
24+
file.sync_all().await?; // tokio doesn't necessarily complete writes until you sync.
2425
assert_eq!(file.metadata().await.unwrap().len(), 10);
2526

2627
remove_file(&path).unwrap();

0 commit comments

Comments
 (0)