Skip to content

Commit

Permalink
test: deflake test-fs-read-optional-params
Browse files Browse the repository at this point in the history
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: #37991
Fixes: #37946
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
  • Loading branch information
lpinca authored and targos committed May 1, 2021
1 parent 8598745 commit d6346e1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/parallel/test-fs-read-optional-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
Expand Down

0 comments on commit d6346e1

Please sign in to comment.