summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLuigi Pinca <luigipinca@gmail.com>2021-03-30 19:45:51 +0200
committerMyles Borins <mylesborins@github.com>2021-04-05 12:57:23 -0400
commit0db1a1eacf4511a0495a22677e1f112d6ebe68f0 (patch)
tree0de4c6899724b531e9214fff8733692d831b171a /test
parent6d28a24f1cf1e9984ea87b986b3b48415d6217d7 (diff)
downloadnode-new-0db1a1eacf4511a0495a22677e1f112d6ebe68f0.tar.gz
test: deflake test-fs-read-optional-params
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 <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-fs-read-optional-params.js8
1 files 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 bae99da3c0..aac5f51d0b 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);
}));