Skip to content

Commit 31cc6e5

Browse files
committed
fix fragile test
1 parent 8ae1ee8 commit 31cc6e5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/io/writer_test.mbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct DummyWriter {
8282

8383
///|
8484
impl @io.Writer for DummyWriter with write_once(self, buf, offset~, len~) {
85-
guard offset < len
85+
guard offset + len <= buf.length()
8686
@async.sleep(self.base_timeout)
8787
self.logger.write_string("writing byte \{buf[offset]}\n")
8888
1
@@ -92,8 +92,8 @@ impl @io.Writer for DummyWriter with write_once(self, buf, offset~, len~) {
9292
async test "write cancel" {
9393
let log = StringBuilder::new()
9494
@async.with_task_group(fn(_) {
95-
let writer = { logger: log, base_timeout: 40 }
96-
@async.with_timeout_opt(60, fn() { writer.write(b"abcd") }) |> ignore
95+
let writer = { logger: log, base_timeout: 300 }
96+
@async.with_timeout_opt(450, fn() { writer.write(b"abcd") }) |> ignore
9797
})
9898
// The `write` here is partial and corrupted,
9999
// but we have no choice because making `write` atomic may cause hang

0 commit comments

Comments
 (0)