GeezerVison is showing github.com — test: use `tmpdir.resolve()` in fs tests · nodejs/node@b3c56d2
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises-file-handle-aggregate-errors.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,7 +7,6 @@ const tmpdir = require('../common/tmpdir'); | 7 | 7 | // The following tests validate aggregate errors are thrown correctly | 8 | 8 | // when both an operation and close throw. | 9 | 9 |
| 10 | | -const path = require('path'); | 11 | 10 | const { | 12 | 11 | readFile, | 13 | 12 | writeFile, | @@ -23,7 +22,7 @@ const originalFd = Object.getOwnPropertyDescriptor(FileHandle.prototype, 'fd'); | 23 | 22 |
| 24 | 23 | let count = 0; | 25 | 24 | async function createFile() { | 26 | | - const filePath = path.join(tmpdir.path, `aggregate_errors_${++count}.txt`); | | 25 | + const filePath = tmpdir.resolve(`aggregate_errors_${++count}.txt`); | 27 | 26 | await writeFile(filePath, 'content'); | 28 | 27 | return filePath; | 29 | 28 | } | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises-file-handle-close-errors.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,7 +7,6 @@ const tmpdir = require('../common/tmpdir'); | 7 | 7 | // The following tests validate aggregate errors are thrown correctly | 8 | 8 | // when both an operation and close throw. | 9 | 9 |
| 10 | | -const path = require('path'); | 11 | 10 | const { | 12 | 11 | readFile, | 13 | 12 | writeFile, | @@ -23,7 +22,7 @@ const originalFd = Object.getOwnPropertyDescriptor(FileHandle.prototype, 'fd'); | 23 | 22 |
| 24 | 23 | let count = 0; | 25 | 24 | async function createFile() { | 26 | | - const filePath = path.join(tmpdir.path, `close_errors_${++count}.txt`); | | 25 | + const filePath = tmpdir.resolve(`close_errors_${++count}.txt`); | 27 | 26 | await writeFile(filePath, 'content'); | 28 | 27 | return filePath; | 29 | 28 | } | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises-file-handle-op-errors.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,7 +7,6 @@ const tmpdir = require('../common/tmpdir'); | 7 | 7 | // The following tests validate aggregate errors are thrown correctly | 8 | 8 | // when both an operation and close throw. | 9 | 9 |
| 10 | | -const path = require('path'); | 11 | 10 | const { | 12 | 11 | readFile, | 13 | 12 | writeFile, | @@ -23,7 +22,7 @@ const originalFd = Object.getOwnPropertyDescriptor(FileHandle.prototype, 'fd'); | 23 | 22 |
| 24 | 23 | let count = 0; | 25 | 24 | async function createFile() { | 26 | | - const filePath = path.join(tmpdir.path, `op_errors_${++count}.txt`); | | 25 | + const filePath = tmpdir.resolve(`op_errors_${++count}.txt`); | 27 | 26 | await writeFile(filePath, 'content'); | 28 | 27 | return filePath; | 29 | 28 | } | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises-file-handle-read-worker.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | const common = require('../common'); | 3 | 3 | const fs = require('fs'); | 4 | 4 | const assert = require('assert'); | 5 | | -const path = require('path'); | 6 | 5 | const tmpdir = require('../common/tmpdir'); | 7 | | -const file = path.join(tmpdir.path, 'read_stream_filehandle_worker.txt'); | | 6 | +const file = tmpdir.resolve('read_stream_filehandle_worker.txt'); | 8 | 7 | const input = 'hello world'; | 9 | 8 | const { Worker, isMainThread, workerData } = require('worker_threads'); | 10 | 9 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises-file-handle-readLines.mjs +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,11 +3,10 @@ import tmpdir from '../common/tmpdir.js'; | 3 | 3 |
| 4 | 4 | import assert from 'node:assert'; | 5 | 5 | import { open, writeFile } from 'node:fs/promises'; | 6 | | -import path from 'node:path'; | 7 | 6 |
| 8 | 7 | tmpdir.refresh(); | 9 | 8 |
| 10 | | -const filePath = path.join(tmpdir.path, 'file.txt'); | | 9 | +const filePath = tmpdir.resolve('file.txt'); | 11 | 10 |
| 12 | 11 | await writeFile(filePath, '1\n\n2\n'); | 13 | 12 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises-file-handle-stat.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -6,14 +6,13 @@ const common = require('../common'); | 6 | 6 | // FileHandle.stat method. | 7 | 7 |
| 8 | 8 | const { open } = require('fs').promises; | 9 | | -const path = require('path'); | 10 | 9 | const tmpdir = require('../common/tmpdir'); | 11 | 10 | const assert = require('assert'); | 12 | 11 |
| 13 | 12 | tmpdir.refresh(); | 14 | 13 |
| 15 | 14 | async function validateStat() { | 16 | | - const filePath = path.resolve(tmpdir.path, 'tmp-read-file.txt'); | | 15 | + const filePath = tmpdir.resolve('tmp-read-file.txt'); | 17 | 16 | const fileHandle = await open(filePath, 'w+'); | 18 | 17 | const stats = await fileHandle.stat(); | 19 | 18 | assert.ok(stats.mtime instanceof Date); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises-file-handle-sync.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,11 +5,10 @@ const fixtures = require('../common/fixtures'); | 5 | 5 | const tmpdir = require('../common/tmpdir'); | 6 | 6 |
| 7 | 7 | const { access, copyFile, open } = require('fs').promises; | 8 | | -const path = require('path'); | 9 | 8 |
| 10 | 9 | async function validate() { | 11 | 10 | tmpdir.refresh(); | 12 | | - const dest = path.resolve(tmpdir.path, 'baz.js'); | | 11 | + const dest = tmpdir.resolve('baz.js'); | 13 | 12 | await assert.rejects( | 14 | 13 | copyFile(fixtures.path('baz.js'), dest, 'r'), | 15 | 14 | { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises-file-handle-truncate.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | const common = require('../common'); | 4 | 4 | const assert = require('assert'); | 5 | | -const path = require('path'); | 6 | 5 | const { open, readFile } = require('fs').promises; | 7 | 6 | const tmpdir = require('../common/tmpdir'); | 8 | 7 |
| 9 | 8 | tmpdir.refresh(); | 10 | 9 |
| 11 | 10 | async function validateTruncate() { | 12 | 11 | const text = 'Hello world'; | 13 | | - const filename = path.resolve(tmpdir.path, 'truncate-file.txt'); | | 12 | + const filename = tmpdir.resolve('truncate-file.txt'); | 14 | 13 | const fileHandle = await open(filename, 'w+'); | 15 | 14 |
| 16 | 15 | const buffer = Buffer.from(text, 'utf8'); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises-readfile-with-fd.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 |
| 6 | 6 | const common = require('../common'); | 7 | 7 | const assert = require('assert'); | 8 | | -const path = require('path'); | 9 | 8 | const { writeFileSync } = require('fs'); | 10 | 9 | const { open } = require('fs').promises; | 11 | 10 |
| 12 | 11 | const tmpdir = require('../common/tmpdir'); | 13 | 12 | tmpdir.refresh(); | 14 | 13 |
| 15 | | -const fn = path.join(tmpdir.path, 'test.txt'); | | 14 | +const fn = tmpdir.resolve('test.txt'); | 16 | 15 | writeFileSync(fn, 'Hello World'); | 17 | 16 |
| 18 | 17 | async function readFileTest() { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises-readfile.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 4 | 4 | const common = require('../common'); | 5 | 5 |
| 6 | 6 | const assert = require('assert'); | 7 | | -const path = require('path'); | 8 | 7 | const { writeFile, readFile } = require('fs').promises; | 9 | 8 | const tmpdir = require('../common/tmpdir'); | 10 | 9 | const { internalBinding } = require('internal/test/binding'); | 11 | 10 | const fsBinding = internalBinding('fs'); | 12 | 11 | tmpdir.refresh(); | 13 | 12 |
| 14 | | -const fn = path.join(tmpdir.path, 'large-file'); | | 13 | +const fn = tmpdir.resolve('large-file'); | 15 | 14 |
| 16 | 15 | // Creating large buffer with random content | 17 | 16 | const largeBuffer = Buffer.from( | |
|