From 0db1a1eacf4511a0495a22677e1f112d6ebe68f0 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Tue, 30 Mar 2021 19:45:51 +0200 Subject: [PATCH] test: deflake test-fs-read-optional-params MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If `fs.read()` is called without specifying the `position` option, data will be read from the current file position. There is another concurrent `fs.read()` call before the test for no options object which might invalidate the test expectations. Run the test for no options object first. PR-URL: https://github.com/nodejs/node/pull/37991 Fixes: https://github.com/nodejs/node/issues/37946 Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: Darshan Sen --- test/parallel/test-fs-read-optional-params.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-fs-read-optional-params.js b/test/parallel/test-fs-read-optional-params.js index bae99da3c0ebd0..aac5f51d0bb2db 100644 --- a/test/parallel/test-fs-read-optional-params.js +++ b/test/parallel/test-fs-read-optional-params.js @@ -11,14 +11,14 @@ const expected = Buffer.from('xyz\n'); const defaultBufferAsync = Buffer.alloc(16384); const bufferAsOption = Buffer.allocUnsafe(expected.length); -// Test passing in an empty options object -fs.read(fd, { position: 0 }, common.mustCall((err, bytesRead, buffer) => { +// Test not passing in any options object +fs.read(fd, common.mustCall((err, bytesRead, buffer) => { assert.strictEqual(bytesRead, expected.length); assert.deepStrictEqual(defaultBufferAsync.length, buffer.length); })); -// Test not passing in any options object -fs.read(fd, common.mustCall((err, bytesRead, buffer) => { +// Test passing in an empty options object +fs.read(fd, { position: 0 }, common.mustCall((err, bytesRead, buffer) => { assert.strictEqual(bytesRead, expected.length); assert.deepStrictEqual(defaultBufferAsync.length, buffer.length); }));