GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: dispose of filehandles in filehandle.read tests · nodejs/node@8347ef6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-fs-read-empty-buffer.js
    • test-fs-read-offset-null.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-fs-read-empty-buffer.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-read-empty-buffer.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ assert.throws(
2929
);
3030

3131
(async () => {
32-
const filehandle = await fsPromises.open(filepath, 'r');
32+
await using filehandle = await fsPromises.open(filepath, 'r');
3333
assert.rejects(
3434
() => filehandle.read(buffer, 0, 1, 0),
3535
{
Collapse file

‎test/parallel/test-fs-read-offset-null.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-read-offset-null.js
+3-8Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,25 @@ fs.open(filepath, 'r', common.mustSucceed((fd) => {
3535
}));
3636
}));
3737

38-
let filehandle = null;
39-
4038
// Tests for promises api
4139
(async () => {
42-
filehandle = await fsPromises.open(filepath, 'r');
40+
await using filehandle = await fsPromises.open(filepath, 'r');
4341
const readObject = await filehandle.read(buf, { offset: null });
4442
assert.strictEqual(readObject.buffer[0], 120);
4543
})()
46-
.finally(() => filehandle?.close())
4744
.then(common.mustCall());
4845

4946
// Undocumented: omitted position works the same as position === null
5047
(async () => {
51-
filehandle = await fsPromises.open(filepath, 'r');
48+
await using filehandle = await fsPromises.open(filepath, 'r');
5249
const readObject = await filehandle.read(buf, null, buf.length);
5350
assert.strictEqual(readObject.buffer[0], 120);
5451
})()
55-
.finally(() => filehandle?.close())
5652
.then(common.mustCall());
5753

5854
(async () => {
59-
filehandle = await fsPromises.open(filepath, 'r');
55+
await using filehandle = await fsPromises.open(filepath, 'r');
6056
const readObject = await filehandle.read(buf, null, buf.length, 0);
6157
assert.strictEqual(readObject.buffer[0], 120);
6258
})()
63-
.finally(() => filehandle?.close())
6459
.then(common.mustCall());

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.