Merge pull request #4370 from Noratrieb/fix-for-real

Make sure to sync on file-io.rs tokio test
This commit is contained in:
Ralf Jung 2025-06-01 14:58:14 +00:00 committed by GitHub
commit c10a629224
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,6 +21,10 @@ async fn test_create_and_write() -> io::Result<()> {
// Write 10 bytes to the file.
file.write_all(b"some bytes").await?;
// For tokio's file I/O, `await` does not have its usual semantics of waiting until the
// operation is completed, so we have to wait some more to make sure the write is completed.
file.flush().await?;
// Check that 10 bytes have been written.
assert_eq!(file.metadata().await.unwrap().len(), 10);
remove_file(&path).unwrap();