Skip to content

Commit

Permalink
test: fix flaky parallel/test-fs-write-file-typedarrays
Browse files Browse the repository at this point in the history
Using the same filename for different async tests could lead
to race conditions.

Example failure: https://travis-ci.com/nodejs/node/jobs/143351655

Refs: nodejs#22150
  • Loading branch information
addaleax committed Sep 2, 2018
1 parent f911e09 commit 40b718f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/parallel/test-fs-write-file-typedarrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ for (const expectView of common.getArrayBufferViews(inputBuffer)) {

for (const expectView of common.getArrayBufferViews(inputBuffer)) {
console.log('Async test for ', expectView[Symbol.toStringTag]);
fs.writeFile(filename, expectView, common.mustCall((e) => {
const file = `${filename}-${expectView[Symbol.toStringTag]}`;
fs.writeFile(file, expectView, common.mustCall((e) => {
assert.ifError(e);

fs.readFile(filename, 'utf8', common.mustCall((err, data) => {
fs.readFile(file, 'utf8', common.mustCall((err, data) => {
assert.ifError(err);
assert.strictEqual(data, inputBuffer.toString('utf8'));
}));
Expand Down

0 comments on commit 40b718f

Please sign in to comment.