Skip to content

Commit 0db1a1e

Browse files
lpincaMylesBorins
authored andcommitted
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: #37991 Fixes: #37946 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent 6d28a24 commit 0db1a1e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/parallel/test-fs-read-optional-params.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ const expected = Buffer.from('xyz\n');
1111
const defaultBufferAsync = Buffer.alloc(16384);
1212
const bufferAsOption = Buffer.allocUnsafe(expected.length);
1313

14-
// Test passing in an empty options object
15-
fs.read(fd, { position: 0 }, common.mustCall((err, bytesRead, buffer) => {
14+
// Test not passing in any options object
15+
fs.read(fd, common.mustCall((err, bytesRead, buffer) => {
1616
assert.strictEqual(bytesRead, expected.length);
1717
assert.deepStrictEqual(defaultBufferAsync.length, buffer.length);
1818
}));
1919

20-
// Test not passing in any options object
21-
fs.read(fd, common.mustCall((err, bytesRead, buffer) => {
20+
// Test passing in an empty options object
21+
fs.read(fd, { position: 0 }, common.mustCall((err, bytesRead, buffer) => {
2222
assert.strictEqual(bytesRead, expected.length);
2323
assert.deepStrictEqual(defaultBufferAsync.length, buffer.length);
2424
}));

0 commit comments

Comments
 (0)