diff options
| author | Noratrieb <48135649+Noratrieb@users.noreply.github.com> | 2025-06-01 11:43:55 +0200 |
|---|---|---|
| committer | Noratrieb <48135649+Noratrieb@users.noreply.github.com> | 2025-06-01 11:43:55 +0200 |
| commit | 9f8e157a1f1942dcde6489b047aedcadc5a887a3 (patch) | |
| tree | 1d71ff692d8541047935bf27ca69532b855fbf47 | |
| parent | af0829b9f1875e811f5a8bb1d7cdca76aa596248 (diff) | |
| download | rust-9f8e157a1f1942dcde6489b047aedcadc5a887a3.tar.gz rust-9f8e157a1f1942dcde6489b047aedcadc5a887a3.zip | |
Fix tokio/file-io.rs test relying on `read`/`write` not being short
The test did `write` and `read` and hoped that it would read/write everything, which doesn't always happen and caused CI failures. Switch to `write_all` and `read_to_end` to make it more reliable.
| -rw-r--r-- | src/tools/miri/tests/pass-dep/tokio/file-io.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tools/miri/tests/pass-dep/tokio/file-io.rs b/src/tools/miri/tests/pass-dep/tokio/file-io.rs index 6e88b907f5d..e4e92349970 100644 --- a/src/tools/miri/tests/pass-dep/tokio/file-io.rs +++ b/src/tools/miri/tests/pass-dep/tokio/file-io.rs @@ -20,7 +20,7 @@ async fn test_create_and_write() -> io::Result<()> { let mut file = File::create(&path).await?; // Write 10 bytes to the file. - file.write(b"some bytes").await?; + file.write_all(b"some bytes").await?; assert_eq!(file.metadata().await.unwrap().len(), 10); remove_file(&path).unwrap(); @@ -31,10 +31,10 @@ async fn test_create_and_read() -> io::Result<()> { let bytes = b"more bytes"; let path = utils::prepare_with_content("foo.txt", bytes); let mut file = OpenOptions::new().read(true).open(&path).await.unwrap(); - let mut buffer = [0u8; 10]; + let mut buffer = vec![]; // Read the whole file. - file.read(&mut buffer[..]).await?; + file.read_to_end(&mut buffer).await?; assert_eq!(&buffer, b"more bytes"); remove_file(&path).unwrap(); |
