Skip to content

Commit d84ec98

Browse files
LiviaMedeirosrluvaton
authored andcommitted
test: use tmpdir.resolve() in fs tests
PR-URL: nodejs#49125 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
1 parent 6394e1a commit d84ec98

File tree

58 files changed

+95
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+95
-155
lines changed

test/parallel/test-fs-promises-file-handle-aggregate-errors.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const tmpdir = require('../common/tmpdir');
77
// The following tests validate aggregate errors are thrown correctly
88
// when both an operation and close throw.
99

10-
const path = require('path');
1110
const {
1211
readFile,
1312
writeFile,
@@ -23,7 +22,7 @@ const originalFd = Object.getOwnPropertyDescriptor(FileHandle.prototype, 'fd');
2322

2423
let count = 0;
2524
async function createFile() {
26-
const filePath = path.join(tmpdir.path, `aggregate_errors_${++count}.txt`);
25+
const filePath = tmpdir.resolve(`aggregate_errors_${++count}.txt`);
2726
await writeFile(filePath, 'content');
2827
return filePath;
2928
}

test/parallel/test-fs-promises-file-handle-close-errors.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const tmpdir = require('../common/tmpdir');
77
// The following tests validate aggregate errors are thrown correctly
88
// when both an operation and close throw.
99

10-
const path = require('path');
1110
const {
1211
readFile,
1312
writeFile,
@@ -23,7 +22,7 @@ const originalFd = Object.getOwnPropertyDescriptor(FileHandle.prototype, 'fd');
2322

2423
let count = 0;
2524
async function createFile() {
26-
const filePath = path.join(tmpdir.path, `close_errors_${++count}.txt`);
25+
const filePath = tmpdir.resolve(`close_errors_${++count}.txt`);
2726
await writeFile(filePath, 'content');
2827
return filePath;
2928
}

test/parallel/test-fs-promises-file-handle-op-errors.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const tmpdir = require('../common/tmpdir');
77
// The following tests validate aggregate errors are thrown correctly
88
// when both an operation and close throw.
99

10-
const path = require('path');
1110
const {
1211
readFile,
1312
writeFile,
@@ -23,7 +22,7 @@ const originalFd = Object.getOwnPropertyDescriptor(FileHandle.prototype, 'fd');
2322

2423
let count = 0;
2524
async function createFile() {
26-
const filePath = path.join(tmpdir.path, `op_errors_${++count}.txt`);
25+
const filePath = tmpdir.resolve(`op_errors_${++count}.txt`);
2726
await writeFile(filePath, 'content');
2827
return filePath;
2928
}

test/parallel/test-fs-promises-file-handle-read-worker.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
const common = require('../common');
33
const fs = require('fs');
44
const assert = require('assert');
5-
const path = require('path');
65
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');
87
const input = 'hello world';
98
const { Worker, isMainThread, workerData } = require('worker_threads');
109

test/parallel/test-fs-promises-file-handle-readLines.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import tmpdir from '../common/tmpdir.js';
33

44
import assert from 'node:assert';
55
import { open, writeFile } from 'node:fs/promises';
6-
import path from 'node:path';
76

87
tmpdir.refresh();
98

10-
const filePath = path.join(tmpdir.path, 'file.txt');
9+
const filePath = tmpdir.resolve('file.txt');
1110

1211
await writeFile(filePath, '1\n\n2\n');
1312

test/parallel/test-fs-promises-file-handle-stat.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ const common = require('../common');
66
// FileHandle.stat method.
77

88
const { open } = require('fs').promises;
9-
const path = require('path');
109
const tmpdir = require('../common/tmpdir');
1110
const assert = require('assert');
1211

1312
tmpdir.refresh();
1413

1514
async function validateStat() {
16-
const filePath = path.resolve(tmpdir.path, 'tmp-read-file.txt');
15+
const filePath = tmpdir.resolve('tmp-read-file.txt');
1716
const fileHandle = await open(filePath, 'w+');
1817
const stats = await fileHandle.stat();
1918
assert.ok(stats.mtime instanceof Date);

test/parallel/test-fs-promises-file-handle-sync.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ const fixtures = require('../common/fixtures');
55
const tmpdir = require('../common/tmpdir');
66

77
const { access, copyFile, open } = require('fs').promises;
8-
const path = require('path');
98

109
async function validate() {
1110
tmpdir.refresh();
12-
const dest = path.resolve(tmpdir.path, 'baz.js');
11+
const dest = tmpdir.resolve('baz.js');
1312
await assert.rejects(
1413
copyFile(fixtures.path('baz.js'), dest, 'r'),
1514
{

test/parallel/test-fs-promises-file-handle-truncate.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
const common = require('../common');
44
const assert = require('assert');
5-
const path = require('path');
65
const { open, readFile } = require('fs').promises;
76
const tmpdir = require('../common/tmpdir');
87

98
tmpdir.refresh();
109

1110
async function validateTruncate() {
1211
const text = 'Hello world';
13-
const filename = path.resolve(tmpdir.path, 'truncate-file.txt');
12+
const filename = tmpdir.resolve('truncate-file.txt');
1413
const fileHandle = await open(filename, 'w+');
1514

1615
const buffer = Buffer.from(text, 'utf8');

test/parallel/test-fs-promises-readfile-with-fd.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55

66
const common = require('../common');
77
const assert = require('assert');
8-
const path = require('path');
98
const { writeFileSync } = require('fs');
109
const { open } = require('fs').promises;
1110

1211
const tmpdir = require('../common/tmpdir');
1312
tmpdir.refresh();
1413

15-
const fn = path.join(tmpdir.path, 'test.txt');
14+
const fn = tmpdir.resolve('test.txt');
1615
writeFileSync(fn, 'Hello World');
1716

1817
async function readFileTest() {

test/parallel/test-fs-promises-readfile.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
const common = require('../common');
55

66
const assert = require('assert');
7-
const path = require('path');
87
const { writeFile, readFile } = require('fs').promises;
98
const tmpdir = require('../common/tmpdir');
109
const { internalBinding } = require('internal/test/binding');
1110
const fsBinding = internalBinding('fs');
1211
tmpdir.refresh();
1312

14-
const fn = path.join(tmpdir.path, 'large-file');
13+
const fn = tmpdir.resolve('large-file');
1514

1615
// Creating large buffer with random content
1716
const largeBuffer = Buffer.from(

0 commit comments

Comments
 (0)