From aaabff710f756f7dc8651b8e92e4cc5147830e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 4 Jul 2023 04:43:04 +0200 Subject: tests: deflake _fs_read_test.ts again (#19705) --- cli/tests/unit_node/_fs/_fs_read_test.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'cli/tests/unit_node') diff --git a/cli/tests/unit_node/_fs/_fs_read_test.ts b/cli/tests/unit_node/_fs/_fs_read_test.ts index ab32b09ab..66906ccbc 100644 --- a/cli/tests/unit_node/_fs/_fs_read_test.ts +++ b/cli/tests/unit_node/_fs/_fs_read_test.ts @@ -132,11 +132,12 @@ Deno.test({ Deno.test({ name: "[std/node/fs] Read fs.read(fd, options, cb) signature", async fn() { + const promise = deferred(); const file = Deno.makeTempFileSync(); Deno.writeTextFileSync(file, "hi there"); const fd = openSync(file, "r+"); const buf = Buffer.alloc(11); - await read( + read( fd, { buffer: buf, @@ -145,15 +146,22 @@ Deno.test({ position: null, }, (err, bytesRead, data) => { - assertEquals(err, null); - assertStrictEquals(bytesRead, 8); - assertEquals( - data, - Buffer.from([104, 105, 32, 116, 104, 101, 114, 101, 0, 0, 0]), - ); + try { + assertEquals(err, null); + assertStrictEquals(bytesRead, 8); + assertEquals( + data, + Buffer.from([104, 105, 32, 116, 104, 101, 114, 101, 0, 0, 0]), + ); + } catch (e) { + promise.reject(e); + return; + } + promise.resolve(); }, ); closeSync(fd); + await promise; }, }); -- cgit v1.2.3