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: #22150

PR-URL: #22659
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
addaleax authored and targos committed Sep 3, 2018
1 parent 71502f2 commit cb15017
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 cb15017

Please sign in to comment.