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: use `tmpdir.resolve()` in fs tests · nodejs/node@661b055

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-fs-access.js
    • test-fs-append-file-sync.js
    • test-fs-append-file.js
    • test-fs-assert-encoding-error.js
    • test-fs-buffer.js
    • test-fs-chmod-mask.js
    • test-fs-chmod.js
    • test-fs-copyfile-respect-permissions.js
    • test-fs-copyfile.js
    • test-fs-cp.mjs
    • test-fs-error-messages.js
    • test-fs-fmap.js
    • test-fs-fsync.js
    • test-fs-lchown.js
    • test-fs-link.js
    • test-fs-long-path.js
    • test-fs-mkdir-mode-mask.js
    • test-fs-mkdir-recursive-eaccess.js
    • test-fs-mkdir-rmdir.js
    • test-fs-mkdir.js
    • test-fs-mkdtemp.js
    • test-fs-non-number-arguments-throw.js
    • test-fs-open-flags.js
    • test-fs-open-mode-mask.js
    • test-fs-open-numeric-flags.js
    • test-fs-options-immutable.js
    • test-fs-promisified.js
    • test-fs-rm.js
    • test-fs-rmdir-recursive-sync-warns-not-found.js
    • test-fs-rmdir-recursive-sync-warns-on-file.js
    • test-fs-rmdir-recursive-throws-not-found.js
    • test-fs-rmdir-recursive-throws-on-file.js
    • test-fs-rmdir-recursive-warns-not-found.js
    • test-fs-rmdir-recursive-warns-on-file.js
    • test-fs-rmdir-recursive.js
    • test-fs-stat-bigint.js
    • test-fs-stat-date.mjs
    • test-fs-stream-fs-options.js
    • test-fs-symlink-buffer-path.js
    • test-fs-symlink-dir-junction-relative.js
    • test-fs-symlink-dir-junction.js
    • test-fs-symlink-dir.js
    • test-fs-symlink.js
    • test-fs-utils-get-dirents.js
    • test-fs-watch-close-when-destroyed.js
    • test-fs-watch-encoding.js
    • test-fs-watch-enoent.js
    • test-fs-watch-file-enoent-after-deletion.js
    • test-fs-watch.js
    • test-fs-watchfile-bigint.js
    • test-fs-watchfile.js

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-fs-access.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-access.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ if (common.isIBMi)
1313

1414
const assert = require('assert');
1515
const fs = require('fs');
16-
const path = require('path');
1716

1817
const { internalBinding } = require('internal/test/binding');
1918
const { UV_ENOENT } = internalBinding('uv');
2019

2120
const tmpdir = require('../common/tmpdir');
22-
const doesNotExist = path.join(tmpdir.path, '__this_should_not_exist');
23-
const readOnlyFile = path.join(tmpdir.path, 'read_only_file');
24-
const readWriteFile = path.join(tmpdir.path, 'read_write_file');
21+
const doesNotExist = tmpdir.resolve('__this_should_not_exist');
22+
const readOnlyFile = tmpdir.resolve('read_only_file');
23+
const readWriteFile = tmpdir.resolve('read_write_file');
2524

2625
function createFileWithPerms(file, mode) {
2726
fs.writeFileSync(file, '');
Collapse file

‎test/parallel/test-fs-append-file-sync.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-append-file-sync.js
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
'use strict';
2323
const common = require('../common');
2424
const assert = require('assert');
25-
const join = require('path').join;
2625
const fs = require('fs');
2726

2827
const currentFileData = 'ABCD';
@@ -40,7 +39,7 @@ const tmpdir = require('../common/tmpdir');
4039
tmpdir.refresh();
4140

4241
// Test that empty file will be created and have content added.
43-
const filename = join(tmpdir.path, 'append-sync.txt');
42+
const filename = tmpdir.resolve('append-sync.txt');
4443

4544
fs.appendFileSync(filename, data);
4645

@@ -49,7 +48,7 @@ const fileData = fs.readFileSync(filename);
4948
assert.strictEqual(Buffer.byteLength(data), fileData.length);
5049

5150
// Test that appends data to a non empty file.
52-
const filename2 = join(tmpdir.path, 'append-sync2.txt');
51+
const filename2 = tmpdir.resolve('append-sync2.txt');
5352
fs.writeFileSync(filename2, currentFileData);
5453

5554
fs.appendFileSync(filename2, data);
@@ -60,7 +59,7 @@ assert.strictEqual(Buffer.byteLength(data) + currentFileData.length,
6059
fileData2.length);
6160

6261
// Test that appendFileSync accepts buffers.
63-
const filename3 = join(tmpdir.path, 'append-sync3.txt');
62+
const filename3 = tmpdir.resolve('append-sync3.txt');
6463
fs.writeFileSync(filename3, currentFileData);
6564

6665
const buf = Buffer.from(data, 'utf8');
@@ -70,7 +69,7 @@ const fileData3 = fs.readFileSync(filename3);
7069

7170
assert.strictEqual(buf.length + currentFileData.length, fileData3.length);
7271

73-
const filename4 = join(tmpdir.path, 'append-sync4.txt');
72+
const filename4 = tmpdir.resolve('append-sync4.txt');
7473
fs.writeFileSync(filename4, currentFileData, common.mustNotMutateObjectDeep({ mode: m }));
7574

7675
[
@@ -95,7 +94,7 @@ assert.strictEqual(Buffer.byteLength(String(num)) + currentFileData.length,
9594
fileData4.length);
9695

9796
// Test that appendFile accepts file descriptors.
98-
const filename5 = join(tmpdir.path, 'append-sync5.txt');
97+
const filename5 = tmpdir.resolve('append-sync5.txt');
9998
fs.writeFileSync(filename5, currentFileData);
10099

101100
const filename5fd = fs.openSync(filename5, 'a+', 0o600);
Collapse file

‎test/parallel/test-fs-append-file.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-append-file.js
+10-11Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
const common = require('../common');
2424
const assert = require('assert');
2525
const fs = require('fs');
26-
const join = require('path').join;
2726

2827
const tmpdir = require('../common/tmpdir');
2928

@@ -43,7 +42,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
4342

4443
// Test that empty file will be created and have content added (callback API).
4544
{
46-
const filename = join(tmpdir.path, 'append.txt');
45+
const filename = tmpdir.resolve('append.txt');
4746

4847
fs.appendFile(filename, s, common.mustSucceed(() => {
4948
fs.readFile(filename, common.mustSucceed((buffer) => {
@@ -54,7 +53,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
5453

5554
// Test that empty file will be created and have content added (promise API).
5655
{
57-
const filename = join(tmpdir.path, 'append-promise.txt');
56+
const filename = tmpdir.resolve('append-promise.txt');
5857

5958
fs.promises.appendFile(filename, s)
6059
.then(common.mustCall(() => fs.promises.readFile(filename)))
@@ -66,7 +65,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
6665

6766
// Test that appends data to a non-empty file (callback API).
6867
{
69-
const filename = join(tmpdir.path, 'append-non-empty.txt');
68+
const filename = tmpdir.resolve('append-non-empty.txt');
7069
fs.writeFileSync(filename, currentFileData);
7170

7271
fs.appendFile(filename, s, common.mustSucceed(() => {
@@ -79,7 +78,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
7978

8079
// Test that appends data to a non-empty file (promise API).
8180
{
82-
const filename = join(tmpdir.path, 'append-non-empty-promise.txt');
81+
const filename = tmpdir.resolve('append-non-empty-promise.txt');
8382
fs.writeFileSync(filename, currentFileData);
8483

8584
fs.promises.appendFile(filename, s)
@@ -93,7 +92,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
9392

9493
// Test that appendFile accepts buffers (callback API).
9594
{
96-
const filename = join(tmpdir.path, 'append-buffer.txt');
95+
const filename = tmpdir.resolve('append-buffer.txt');
9796
fs.writeFileSync(filename, currentFileData);
9897

9998
const buf = Buffer.from(s, 'utf8');
@@ -107,7 +106,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
107106

108107
// Test that appendFile accepts buffers (promises API).
109108
{
110-
const filename = join(tmpdir.path, 'append-buffer-promises.txt');
109+
const filename = tmpdir.resolve('append-buffer-promises.txt');
111110
fs.writeFileSync(filename, currentFileData);
112111

113112
const buf = Buffer.from(s, 'utf8');
@@ -126,7 +125,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
126125
code: 'ERR_INVALID_ARG_TYPE',
127126
message: /"data"|"buffer"/
128127
};
129-
const filename = join(tmpdir.path, 'append-invalid-data.txt');
128+
const filename = tmpdir.resolve('append-invalid-data.txt');
130129

131130
assert.throws(
132131
() => fs.appendFile(filename, data, common.mustNotCall()),
@@ -154,7 +153,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
154153

155154
// Test that appendFile accepts file descriptors (callback API).
156155
{
157-
const filename = join(tmpdir.path, 'append-descriptors.txt');
156+
const filename = tmpdir.resolve('append-descriptors.txt');
158157
fs.writeFileSync(filename, currentFileData);
159158

160159
fs.open(filename, 'a+', common.mustSucceed((fd) => {
@@ -171,7 +170,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
171170

172171
// Test that appendFile accepts file descriptors (promises API).
173172
{
174-
const filename = join(tmpdir.path, 'append-descriptors-promises.txt');
173+
const filename = tmpdir.resolve('append-descriptors-promises.txt');
175174
fs.writeFileSync(filename, currentFileData);
176175

177176
let fd;
@@ -190,5 +189,5 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
190189
}
191190

192191
assert.throws(
193-
() => fs.appendFile(join(tmpdir.path, 'append6.txt'), console.log),
192+
() => fs.appendFile(tmpdir.resolve('append6.txt'), console.log),
194193
{ code: 'ERR_INVALID_ARG_TYPE' });
Collapse file

‎test/parallel/test-fs-assert-encoding-error.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-assert-encoding-error.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
const common = require('../common');
33
const assert = require('node:assert');
44
const fs = require('node:fs');
5-
const path = require('node:path');
65
const tmpdir = require('../common/tmpdir');
76

8-
const testPath = path.join(tmpdir.path, 'assert-encoding-error');
7+
const testPath = tmpdir.resolve('assert-encoding-error');
98
const options = 'test';
109
const expectedError = {
1110
code: 'ERR_INVALID_ARG_VALUE',
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-fs-buffer.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ const common = require('../common');
44
const fixtures = require('../common/fixtures');
55
const assert = require('assert');
66
const fs = require('fs');
7-
const path = require('path');
87

98
const tmpdir = require('../common/tmpdir');
109
tmpdir.refresh();
1110

1211
fs.access(Buffer.from(tmpdir.path), common.mustSucceed());
1312

14-
const buf = Buffer.from(path.join(tmpdir.path, 'a.txt'));
13+
const buf = Buffer.from(tmpdir.resolve('a.txt'));
1514
fs.open(buf, 'w+', common.mustSucceed((fd) => {
1615
assert(fd);
1716
fs.close(fd, common.mustSucceed());
Collapse file

‎test/parallel/test-fs-chmod-mask.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-chmod-mask.js
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
const common = require('../common');
66
const assert = require('assert');
7-
const path = require('path');
87
const fs = require('fs');
98

109
let mode;
@@ -26,7 +25,7 @@ function test(mode, asString) {
2625
(mode | maskToIgnore).toString(8) : (mode | maskToIgnore);
2726

2827
{
29-
const file = path.join(tmpdir.path, `chmod-async-${suffix}.txt`);
28+
const file = tmpdir.resolve(`chmod-async-${suffix}.txt`);
3029
fs.writeFileSync(file, 'test', 'utf-8');
3130

3231
fs.chmod(file, input, common.mustSucceed(() => {
@@ -35,15 +34,15 @@ function test(mode, asString) {
3534
}
3635

3736
{
38-
const file = path.join(tmpdir.path, `chmodSync-${suffix}.txt`);
37+
const file = tmpdir.resolve(`chmodSync-${suffix}.txt`);
3938
fs.writeFileSync(file, 'test', 'utf-8');
4039

4140
fs.chmodSync(file, input);
4241
assert.strictEqual(fs.statSync(file).mode & 0o777, mode);
4342
}
4443

4544
{
46-
const file = path.join(tmpdir.path, `fchmod-async-${suffix}.txt`);
45+
const file = tmpdir.resolve(`fchmod-async-${suffix}.txt`);
4746
fs.writeFileSync(file, 'test', 'utf-8');
4847
fs.open(file, 'w', common.mustSucceed((fd) => {
4948
fs.fchmod(fd, input, common.mustSucceed(() => {
@@ -54,7 +53,7 @@ function test(mode, asString) {
5453
}
5554

5655
{
57-
const file = path.join(tmpdir.path, `fchmodSync-${suffix}.txt`);
56+
const file = tmpdir.resolve(`fchmodSync-${suffix}.txt`);
5857
fs.writeFileSync(file, 'test', 'utf-8');
5958
const fd = fs.openSync(file, 'w');
6059

@@ -65,8 +64,8 @@ function test(mode, asString) {
6564
}
6665

6766
if (fs.lchmod) {
68-
const link = path.join(tmpdir.path, `lchmod-src-${suffix}`);
69-
const file = path.join(tmpdir.path, `lchmod-dest-${suffix}`);
67+
const link = tmpdir.resolve(`lchmod-src-${suffix}`);
68+
const file = tmpdir.resolve(`lchmod-dest-${suffix}`);
7069
fs.writeFileSync(file, 'test', 'utf-8');
7170
fs.symlinkSync(file, link);
7271

@@ -76,8 +75,8 @@ function test(mode, asString) {
7675
}
7776

7877
if (fs.lchmodSync) {
79-
const link = path.join(tmpdir.path, `lchmodSync-src-${suffix}`);
80-
const file = path.join(tmpdir.path, `lchmodSync-dest-${suffix}`);
78+
const link = tmpdir.resolve(`lchmodSync-src-${suffix}`);
79+
const file = tmpdir.resolve(`lchmodSync-dest-${suffix}`);
8180
fs.writeFileSync(file, 'test', 'utf-8');
8281
fs.symlinkSync(file, link);
8382

Collapse file

‎test/parallel/test-fs-chmod.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-chmod.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
'use strict';
2323
const common = require('../common');
2424
const assert = require('assert');
25-
const path = require('path');
2625
const fs = require('fs');
2726

2827
let mode_async;
@@ -74,8 +73,8 @@ if (common.isWindows) {
7473
const tmpdir = require('../common/tmpdir');
7574
tmpdir.refresh();
7675

77-
const file1 = path.join(tmpdir.path, 'a.js');
78-
const file2 = path.join(tmpdir.path, 'a1.js');
76+
const file1 = tmpdir.resolve('a.js');
77+
const file2 = tmpdir.resolve('a1.js');
7978

8079
// Create file1.
8180
fs.closeSync(fs.openSync(file1, 'w'));
@@ -123,7 +122,7 @@ fs.open(file2, 'w', common.mustSucceed((fd) => {
123122

124123
// lchmod
125124
if (fs.lchmod) {
126-
const link = path.join(tmpdir.path, 'symbolic-link');
125+
const link = tmpdir.resolve('symbolic-link');
127126

128127
fs.symlinkSync(file2, link);
129128

Collapse file

‎test/parallel/test-fs-copyfile-respect-permissions.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-copyfile-respect-permissions.js
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ tmpdir.refresh();
1616

1717
const assert = require('assert');
1818
const fs = require('fs');
19-
const path = require('path');
2019

2120
let n = 0;
2221

2322
function beforeEach() {
2423
n++;
25-
const source = path.join(tmpdir.path, `source${n}`);
26-
const dest = path.join(tmpdir.path, `dest${n}`);
24+
const source = tmpdir.resolve(`source${n}`);
25+
const dest = tmpdir.resolve(`dest${n}`);
2726
fs.writeFileSync(source, 'source');
2827
fs.writeFileSync(dest, 'dest');
2928
fs.chmodSync(dest, '444');
Collapse file

‎test/parallel/test-fs-copyfile.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-copyfile.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ const {
1010
UV_ENOENT,
1111
UV_EEXIST
1212
} = internalBinding('uv');
13-
const path = require('path');
1413
const src = fixtures.path('a.js');
15-
const dest = path.join(tmpdir.path, 'copyfile.out');
14+
const dest = tmpdir.resolve('copyfile.out');
1615
const {
1716
COPYFILE_EXCL,
1817
COPYFILE_FICLONE,
Collapse file

‎test/parallel/test-fs-cp.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-cp.mjs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tmpdir.refresh();
2525

2626
let dirc = 0;
2727
function nextdir() {
28-
return join(tmpdir.path, `copy_${++dirc}`);
28+
return tmpdir.resolve(`copy_${++dirc}`);
2929
}
3030

3131
// Synchronous implementation of copy.

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.