Skip to content

Commit 94e36f1

Browse files
committed
test: fix flaky test-fs-write
PR-URL: #18374 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent eb34278 commit 94e36f1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/parallel/test-fs-write.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ const constants = fs.constants;
3434
/* eslint-disable no-undef */
3535
common.allowGlobals(externalizeString, isOneByteString, x);
3636

37+
common.refreshTmpDir();
38+
3739
{
3840
const expected = 'ümlaut eins'; // Must be a unique string.
3941
externalizeString(expected);
@@ -74,8 +76,6 @@ common.allowGlobals(externalizeString, isOneByteString, x);
7476
assert.strictEqual(expected, fs.readFileSync(fn, 'utf8'));
7577
}
7678

77-
common.refreshTmpDir();
78-
7979
fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
8080
assert.ifError(err);
8181

@@ -91,10 +91,10 @@ fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
9191
const written = common.mustCall(function(err, written) {
9292
assert.ifError(err);
9393
assert.strictEqual(0, written);
94+
fs.write(fd, expected, 0, 'utf8', done);
9495
});
9596

9697
fs.write(fd, '', 0, 'utf8', written);
97-
fs.write(fd, expected, 0, 'utf8', done);
9898
}));
9999

100100
const args = constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC;
@@ -113,10 +113,10 @@ fs.open(fn2, args, 0o644, common.mustCall((err, fd) => {
113113
const written = common.mustCall(function(err, written) {
114114
assert.ifError(err);
115115
assert.strictEqual(0, written);
116+
fs.write(fd, expected, 0, 'utf8', done);
116117
});
117118

118119
fs.write(fd, '', 0, 'utf8', written);
119-
fs.write(fd, expected, 0, 'utf8', done);
120120
}));
121121

122122
fs.open(fn3, 'w', 0o644, common.mustCall(function(err, fd) {

0 commit comments

Comments
 (0)