Skip to content

Commit 9f8e157

Browse files
committed
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.
1 parent af0829b commit 9f8e157

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async fn test_create_and_write() -> io::Result<()> {
2020
let mut file = File::create(&path).await?;
2121

2222
// Write 10 bytes to the file.
23-
file.write(b"some bytes").await?;
23+
file.write_all(b"some bytes").await?;
2424
assert_eq!(file.metadata().await.unwrap().len(), 10);
2525

2626
remove_file(&path).unwrap();
@@ -31,10 +31,10 @@ async fn test_create_and_read() -> io::Result<()> {
3131
let bytes = b"more bytes";
3232
let path = utils::prepare_with_content("foo.txt", bytes);
3333
let mut file = OpenOptions::new().read(true).open(&path).await.unwrap();
34-
let mut buffer = [0u8; 10];
34+
let mut buffer = vec![];
3535

3636
// Read the whole file.
37-
file.read(&mut buffer[..]).await?;
37+
file.read_to_end(&mut buffer).await?;
3838
assert_eq!(&buffer, b"more bytes");
3939

4040
remove_file(&path).unwrap();

0 commit comments

Comments
 (0)