Skip to content

Commit 5ed5a86

Browse files
committed
test: close fds properly in tests
Otherwise the unclosed fd may keep the file open which makes subsequent rmdir attempts failed at exit.
1 parent a4ea9fc commit 5ed5a86

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

test/parallel/test-fs-writefile-with-fd.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ tmpdir.refresh();
6666

6767
fs.open(file, 'r', common.mustSucceed((fd) => {
6868
fs.writeFile(fd, 'World', common.expectsError(expectedError));
69+
fs.closeSync(fd);
6970
}));
7071
}
7172

@@ -76,8 +77,11 @@ tmpdir.refresh();
7677
const file = join(tmpdir.path, 'test.txt');
7778

7879
fs.open(file, 'w', common.mustSucceed((fd) => {
79-
fs.writeFile(fd, 'World', { signal }, common.expectsError({
80-
name: 'AbortError'
80+
fs.writeFile(fd, 'World', { signal }, common.mustCall((err) => {
81+
fs.closeSync(fd);
82+
common.expectsError({
83+
name: 'AbortError'
84+
})(err);
8185
}));
8286
}));
8387

0 commit comments

Comments
 (0)