diff --git a/test/parallel/test-fs-access.js b/test/parallel/test-fs-access.js index 66089049e0cf07..d2afc65a11807f 100644 --- a/test/parallel/test-fs-access.js +++ b/test/parallel/test-fs-access.js @@ -13,15 +13,14 @@ if (common.isIBMi) const assert = require('assert'); const fs = require('fs'); -const path = require('path'); const { internalBinding } = require('internal/test/binding'); const { UV_ENOENT } = internalBinding('uv'); const tmpdir = require('../common/tmpdir'); -const doesNotExist = path.join(tmpdir.path, '__this_should_not_exist'); -const readOnlyFile = path.join(tmpdir.path, 'read_only_file'); -const readWriteFile = path.join(tmpdir.path, 'read_write_file'); +const doesNotExist = tmpdir.resolve('__this_should_not_exist'); +const readOnlyFile = tmpdir.resolve('read_only_file'); +const readWriteFile = tmpdir.resolve('read_write_file'); function createFileWithPerms(file, mode) { fs.writeFileSync(file, ''); diff --git a/test/parallel/test-fs-append-file-sync.js b/test/parallel/test-fs-append-file-sync.js index 14f25cf2a7827d..fd6ee690f4ab7d 100644 --- a/test/parallel/test-fs-append-file-sync.js +++ b/test/parallel/test-fs-append-file-sync.js @@ -22,7 +22,6 @@ 'use strict'; const common = require('../common'); const assert = require('assert'); -const join = require('path').join; const fs = require('fs'); const currentFileData = 'ABCD'; @@ -40,7 +39,7 @@ const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); // Test that empty file will be created and have content added. -const filename = join(tmpdir.path, 'append-sync.txt'); +const filename = tmpdir.resolve('append-sync.txt'); fs.appendFileSync(filename, data); @@ -49,7 +48,7 @@ const fileData = fs.readFileSync(filename); assert.strictEqual(Buffer.byteLength(data), fileData.length); // Test that appends data to a non empty file. -const filename2 = join(tmpdir.path, 'append-sync2.txt'); +const filename2 = tmpdir.resolve('append-sync2.txt'); fs.writeFileSync(filename2, currentFileData); fs.appendFileSync(filename2, data); @@ -60,7 +59,7 @@ assert.strictEqual(Buffer.byteLength(data) + currentFileData.length, fileData2.length); // Test that appendFileSync accepts buffers. -const filename3 = join(tmpdir.path, 'append-sync3.txt'); +const filename3 = tmpdir.resolve('append-sync3.txt'); fs.writeFileSync(filename3, currentFileData); const buf = Buffer.from(data, 'utf8'); @@ -70,7 +69,7 @@ const fileData3 = fs.readFileSync(filename3); assert.strictEqual(buf.length + currentFileData.length, fileData3.length); -const filename4 = join(tmpdir.path, 'append-sync4.txt'); +const filename4 = tmpdir.resolve('append-sync4.txt'); fs.writeFileSync(filename4, currentFileData, common.mustNotMutateObjectDeep({ mode: m })); [ @@ -95,7 +94,7 @@ assert.strictEqual(Buffer.byteLength(String(num)) + currentFileData.length, fileData4.length); // Test that appendFile accepts file descriptors. -const filename5 = join(tmpdir.path, 'append-sync5.txt'); +const filename5 = tmpdir.resolve('append-sync5.txt'); fs.writeFileSync(filename5, currentFileData); const filename5fd = fs.openSync(filename5, 'a+', 0o600); diff --git a/test/parallel/test-fs-append-file.js b/test/parallel/test-fs-append-file.js index 20ad2c01758798..2151b5cedd1c9a 100644 --- a/test/parallel/test-fs-append-file.js +++ b/test/parallel/test-fs-append-file.js @@ -23,7 +23,6 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); -const join = require('path').join; const tmpdir = require('../common/tmpdir'); @@ -43,7 +42,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; // Test that empty file will be created and have content added (callback API). { - const filename = join(tmpdir.path, 'append.txt'); + const filename = tmpdir.resolve('append.txt'); fs.appendFile(filename, s, common.mustSucceed(() => { fs.readFile(filename, common.mustSucceed((buffer) => { @@ -54,7 +53,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; // Test that empty file will be created and have content added (promise API). { - const filename = join(tmpdir.path, 'append-promise.txt'); + const filename = tmpdir.resolve('append-promise.txt'); fs.promises.appendFile(filename, s) .then(common.mustCall(() => fs.promises.readFile(filename))) @@ -66,7 +65,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; // Test that appends data to a non-empty file (callback API). { - const filename = join(tmpdir.path, 'append-non-empty.txt'); + const filename = tmpdir.resolve('append-non-empty.txt'); fs.writeFileSync(filename, currentFileData); fs.appendFile(filename, s, common.mustSucceed(() => { @@ -79,7 +78,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; // Test that appends data to a non-empty file (promise API). { - const filename = join(tmpdir.path, 'append-non-empty-promise.txt'); + const filename = tmpdir.resolve('append-non-empty-promise.txt'); fs.writeFileSync(filename, currentFileData); fs.promises.appendFile(filename, s) @@ -93,7 +92,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; // Test that appendFile accepts buffers (callback API). { - const filename = join(tmpdir.path, 'append-buffer.txt'); + const filename = tmpdir.resolve('append-buffer.txt'); fs.writeFileSync(filename, currentFileData); const buf = Buffer.from(s, 'utf8'); @@ -107,7 +106,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; // Test that appendFile accepts buffers (promises API). { - const filename = join(tmpdir.path, 'append-buffer-promises.txt'); + const filename = tmpdir.resolve('append-buffer-promises.txt'); fs.writeFileSync(filename, currentFileData); const buf = Buffer.from(s, 'utf8'); @@ -126,7 +125,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; code: 'ERR_INVALID_ARG_TYPE', message: /"data"|"buffer"/ }; - const filename = join(tmpdir.path, 'append-invalid-data.txt'); + const filename = tmpdir.resolve('append-invalid-data.txt'); assert.throws( () => fs.appendFile(filename, data, common.mustNotCall()), @@ -154,7 +153,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; // Test that appendFile accepts file descriptors (callback API). { - const filename = join(tmpdir.path, 'append-descriptors.txt'); + const filename = tmpdir.resolve('append-descriptors.txt'); fs.writeFileSync(filename, currentFileData); fs.open(filename, 'a+', common.mustSucceed((fd) => { @@ -171,7 +170,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; // Test that appendFile accepts file descriptors (promises API). { - const filename = join(tmpdir.path, 'append-descriptors-promises.txt'); + const filename = tmpdir.resolve('append-descriptors-promises.txt'); fs.writeFileSync(filename, currentFileData); let fd; @@ -190,5 +189,5 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; } assert.throws( - () => fs.appendFile(join(tmpdir.path, 'append6.txt'), console.log), + () => fs.appendFile(tmpdir.resolve('append6.txt'), console.log), { code: 'ERR_INVALID_ARG_TYPE' }); diff --git a/test/parallel/test-fs-assert-encoding-error.js b/test/parallel/test-fs-assert-encoding-error.js index 7f32c06ea89419..9b22e042c528ea 100644 --- a/test/parallel/test-fs-assert-encoding-error.js +++ b/test/parallel/test-fs-assert-encoding-error.js @@ -2,10 +2,9 @@ const common = require('../common'); const assert = require('node:assert'); const fs = require('node:fs'); -const path = require('node:path'); const tmpdir = require('../common/tmpdir'); -const testPath = path.join(tmpdir.path, 'assert-encoding-error'); +const testPath = tmpdir.resolve('assert-encoding-error'); const options = 'test'; const expectedError = { code: 'ERR_INVALID_ARG_VALUE', diff --git a/test/parallel/test-fs-buffer.js b/test/parallel/test-fs-buffer.js index 4c81c13e26977f..8e7eb5d25c3241 100644 --- a/test/parallel/test-fs-buffer.js +++ b/test/parallel/test-fs-buffer.js @@ -4,14 +4,13 @@ const common = require('../common'); const fixtures = require('../common/fixtures'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); fs.access(Buffer.from(tmpdir.path), common.mustSucceed()); -const buf = Buffer.from(path.join(tmpdir.path, 'a.txt')); +const buf = Buffer.from(tmpdir.resolve('a.txt')); fs.open(buf, 'w+', common.mustSucceed((fd) => { assert(fd); fs.close(fd, common.mustSucceed()); diff --git a/test/parallel/test-fs-chmod-mask.js b/test/parallel/test-fs-chmod-mask.js index bd967f5fb62578..53f1931be4cbef 100644 --- a/test/parallel/test-fs-chmod-mask.js +++ b/test/parallel/test-fs-chmod-mask.js @@ -4,7 +4,6 @@ const common = require('../common'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); let mode; @@ -26,7 +25,7 @@ function test(mode, asString) { (mode | maskToIgnore).toString(8) : (mode | maskToIgnore); { - const file = path.join(tmpdir.path, `chmod-async-${suffix}.txt`); + const file = tmpdir.resolve(`chmod-async-${suffix}.txt`); fs.writeFileSync(file, 'test', 'utf-8'); fs.chmod(file, input, common.mustSucceed(() => { @@ -35,7 +34,7 @@ function test(mode, asString) { } { - const file = path.join(tmpdir.path, `chmodSync-${suffix}.txt`); + const file = tmpdir.resolve(`chmodSync-${suffix}.txt`); fs.writeFileSync(file, 'test', 'utf-8'); fs.chmodSync(file, input); @@ -43,7 +42,7 @@ function test(mode, asString) { } { - const file = path.join(tmpdir.path, `fchmod-async-${suffix}.txt`); + const file = tmpdir.resolve(`fchmod-async-${suffix}.txt`); fs.writeFileSync(file, 'test', 'utf-8'); fs.open(file, 'w', common.mustSucceed((fd) => { fs.fchmod(fd, input, common.mustSucceed(() => { @@ -54,7 +53,7 @@ function test(mode, asString) { } { - const file = path.join(tmpdir.path, `fchmodSync-${suffix}.txt`); + const file = tmpdir.resolve(`fchmodSync-${suffix}.txt`); fs.writeFileSync(file, 'test', 'utf-8'); const fd = fs.openSync(file, 'w'); @@ -65,8 +64,8 @@ function test(mode, asString) { } if (fs.lchmod) { - const link = path.join(tmpdir.path, `lchmod-src-${suffix}`); - const file = path.join(tmpdir.path, `lchmod-dest-${suffix}`); + const link = tmpdir.resolve(`lchmod-src-${suffix}`); + const file = tmpdir.resolve(`lchmod-dest-${suffix}`); fs.writeFileSync(file, 'test', 'utf-8'); fs.symlinkSync(file, link); @@ -76,8 +75,8 @@ function test(mode, asString) { } if (fs.lchmodSync) { - const link = path.join(tmpdir.path, `lchmodSync-src-${suffix}`); - const file = path.join(tmpdir.path, `lchmodSync-dest-${suffix}`); + const link = tmpdir.resolve(`lchmodSync-src-${suffix}`); + const file = tmpdir.resolve(`lchmodSync-dest-${suffix}`); fs.writeFileSync(file, 'test', 'utf-8'); fs.symlinkSync(file, link); diff --git a/test/parallel/test-fs-chmod.js b/test/parallel/test-fs-chmod.js index 99e47adc3dcf29..39cb19e410df6b 100644 --- a/test/parallel/test-fs-chmod.js +++ b/test/parallel/test-fs-chmod.js @@ -22,7 +22,6 @@ 'use strict'; const common = require('../common'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); let mode_async; @@ -74,8 +73,8 @@ if (common.isWindows) { const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -const file1 = path.join(tmpdir.path, 'a.js'); -const file2 = path.join(tmpdir.path, 'a1.js'); +const file1 = tmpdir.resolve('a.js'); +const file2 = tmpdir.resolve('a1.js'); // Create file1. fs.closeSync(fs.openSync(file1, 'w')); @@ -123,7 +122,7 @@ fs.open(file2, 'w', common.mustSucceed((fd) => { // lchmod if (fs.lchmod) { - const link = path.join(tmpdir.path, 'symbolic-link'); + const link = tmpdir.resolve('symbolic-link'); fs.symlinkSync(file2, link); diff --git a/test/parallel/test-fs-copyfile-respect-permissions.js b/test/parallel/test-fs-copyfile-respect-permissions.js index cba99ed89984f4..d668ec63ec9a87 100644 --- a/test/parallel/test-fs-copyfile-respect-permissions.js +++ b/test/parallel/test-fs-copyfile-respect-permissions.js @@ -16,14 +16,13 @@ tmpdir.refresh(); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); let n = 0; function beforeEach() { n++; - const source = path.join(tmpdir.path, `source${n}`); - const dest = path.join(tmpdir.path, `dest${n}`); + const source = tmpdir.resolve(`source${n}`); + const dest = tmpdir.resolve(`dest${n}`); fs.writeFileSync(source, 'source'); fs.writeFileSync(dest, 'dest'); fs.chmodSync(dest, '444'); diff --git a/test/parallel/test-fs-copyfile.js b/test/parallel/test-fs-copyfile.js index cbe79adf02c478..51d7153de02535 100644 --- a/test/parallel/test-fs-copyfile.js +++ b/test/parallel/test-fs-copyfile.js @@ -10,9 +10,8 @@ const { UV_ENOENT, UV_EEXIST } = internalBinding('uv'); -const path = require('path'); const src = fixtures.path('a.js'); -const dest = path.join(tmpdir.path, 'copyfile.out'); +const dest = tmpdir.resolve('copyfile.out'); const { COPYFILE_EXCL, COPYFILE_FICLONE, diff --git a/test/parallel/test-fs-cp.mjs b/test/parallel/test-fs-cp.mjs index 8aedad334d2b24..63bc813ae226c7 100644 --- a/test/parallel/test-fs-cp.mjs +++ b/test/parallel/test-fs-cp.mjs @@ -25,7 +25,7 @@ tmpdir.refresh(); let dirc = 0; function nextdir() { - return join(tmpdir.path, `copy_${++dirc}`); + return tmpdir.resolve(`copy_${++dirc}`); } // Synchronous implementation of copy. diff --git a/test/parallel/test-fs-error-messages.js b/test/parallel/test-fs-error-messages.js index 43185725e5fbcd..8c50acbac4b45e 100644 --- a/test/parallel/test-fs-error-messages.js +++ b/test/parallel/test-fs-error-messages.js @@ -26,16 +26,15 @@ const fixtures = require('../common/fixtures'); const tmpdir = require('../common/tmpdir'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); tmpdir.refresh(); -const nonexistentFile = path.join(tmpdir.path, 'non-existent'); -const nonexistentDir = path.join(tmpdir.path, 'non-existent', 'foo', 'bar'); -const existingFile = path.join(tmpdir.path, 'existingFile.js'); -const existingFile2 = path.join(tmpdir.path, 'existingFile2.js'); -const existingDir = path.join(tmpdir.path, 'dir'); +const nonexistentFile = tmpdir.resolve('non-existent'); +const nonexistentDir = tmpdir.resolve('non-existent', 'foo', 'bar'); +const existingFile = tmpdir.resolve('existingFile.js'); +const existingFile2 = tmpdir.resolve('existingFile2.js'); +const existingDir = tmpdir.resolve('dir'); const existingDir2 = fixtures.path('keys'); fs.mkdirSync(existingDir); fs.writeFileSync(existingFile, 'test', 'utf-8'); @@ -297,7 +296,7 @@ function re(literals, ...values) { return true; }; - const destFile = path.join(tmpdir.path, 'foo'); + const destFile = tmpdir.resolve('foo'); fs.rename(nonexistentFile, destFile, common.mustCall(validateError)); assert.throws( diff --git a/test/parallel/test-fs-fmap.js b/test/parallel/test-fs-fmap.js index 4b21ce8d95a12f..c4298f0d0e288b 100644 --- a/test/parallel/test-fs-fmap.js +++ b/test/parallel/test-fs-fmap.js @@ -2,7 +2,6 @@ require('../common'); const assert = require('assert'); const fs = require('fs'); -const join = require('path').join; const { O_CREAT = 0, @@ -18,7 +17,7 @@ tmpdir.refresh(); // Run this test on all platforms. While UV_FS_O_FILEMAP is only available on // Windows, it should be silently ignored on other platforms. -const filename = join(tmpdir.path, 'fmap.txt'); +const filename = tmpdir.resolve('fmap.txt'); const text = 'Memory File Mapping Test'; const mw = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY; diff --git a/test/parallel/test-fs-fsync.js b/test/parallel/test-fs-fsync.js index c60fe0af728e39..6168c08d5b148d 100644 --- a/test/parallel/test-fs-fsync.js +++ b/test/parallel/test-fs-fsync.js @@ -26,10 +26,9 @@ const fixtures = require('../common/fixtures'); const tmpdir = require('../common/tmpdir'); const fs = require('fs'); -const path = require('path'); const fileFixture = fixtures.path('a.js'); -const fileTemp = path.join(tmpdir.path, 'a.js'); +const fileTemp = tmpdir.resolve('a.js'); // Copy fixtures to temp. tmpdir.refresh(); diff --git a/test/parallel/test-fs-lchown.js b/test/parallel/test-fs-lchown.js index 899f9c630188d6..d2a97186859318 100644 --- a/test/parallel/test-fs-lchown.js +++ b/test/parallel/test-fs-lchown.js @@ -51,7 +51,7 @@ const { promises } = fs; }); if (!common.isWindows) { - const testFile = path.join(tmpdir.path, path.basename(__filename)); + const testFile = tmpdir.resolve(path.basename(__filename)); const uid = process.geteuid(); const gid = process.getegid(); diff --git a/test/parallel/test-fs-link.js b/test/parallel/test-fs-link.js index ffa0e0bc635707..df5f606d0ca602 100644 --- a/test/parallel/test-fs-link.js +++ b/test/parallel/test-fs-link.js @@ -1,15 +1,14 @@ 'use strict'; const common = require('../common'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); // Test creating and reading hard link -const srcPath = path.join(tmpdir.path, 'hardlink-target.txt'); -const dstPath = path.join(tmpdir.path, 'link1.js'); +const srcPath = tmpdir.resolve('hardlink-target.txt'); +const dstPath = tmpdir.resolve('link1.js'); fs.writeFileSync(srcPath, 'hello world'); function callback(err) { diff --git a/test/parallel/test-fs-long-path.js b/test/parallel/test-fs-long-path.js index 3f808496ae53f2..f3a8ea7a9ebf9e 100644 --- a/test/parallel/test-fs-long-path.js +++ b/test/parallel/test-fs-long-path.js @@ -31,7 +31,7 @@ const tmpdir = require('../common/tmpdir'); // Make a path that will be at least 260 chars long. const fileNameLen = Math.max(260 - tmpdir.path.length - 1, 1); -const fileName = path.join(tmpdir.path, 'x'.repeat(fileNameLen)); +const fileName = tmpdir.resolve('x'.repeat(fileNameLen)); const fullPath = path.resolve(fileName); tmpdir.refresh(); diff --git a/test/parallel/test-fs-mkdir-mode-mask.js b/test/parallel/test-fs-mkdir-mode-mask.js index 6e11d0fb2e36eb..cca28ca5ffb4c2 100644 --- a/test/parallel/test-fs-mkdir-mode-mask.js +++ b/test/parallel/test-fs-mkdir-mode-mask.js @@ -4,7 +4,6 @@ const common = require('../common'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); if (common.isWindows) { @@ -24,13 +23,13 @@ function test(mode, asString) { (mode | maskToIgnore).toString(8) : (mode | maskToIgnore); { - const dir = path.join(tmpdir.path, `mkdirSync-${suffix}`); + const dir = tmpdir.resolve(`mkdirSync-${suffix}`); fs.mkdirSync(dir, input); assert.strictEqual(fs.statSync(dir).mode & 0o777, mode); } { - const dir = path.join(tmpdir.path, `mkdir-${suffix}`); + const dir = tmpdir.resolve(`mkdir-${suffix}`); fs.mkdir(dir, input, common.mustSucceed(() => { assert.strictEqual(fs.statSync(dir).mode & 0o777, mode); })); diff --git a/test/parallel/test-fs-mkdir-recursive-eaccess.js b/test/parallel/test-fs-mkdir-recursive-eaccess.js index c07f8cbd1bf4e5..034a23094883af 100644 --- a/test/parallel/test-fs-mkdir-recursive-eaccess.js +++ b/test/parallel/test-fs-mkdir-recursive-eaccess.js @@ -41,7 +41,7 @@ function makeDirectoryWritable(dir) { // Synchronous API should return an EACCESS error with path populated. { - const dir = path.join(tmpdir.path, `mkdirp_${n++}`); + const dir = tmpdir.resolve(`mkdirp_${n++}`); fs.mkdirSync(dir); const codeExpected = makeDirectoryReadOnly(dir); let err = null; @@ -58,7 +58,7 @@ function makeDirectoryWritable(dir) { // Asynchronous API should return an EACCESS error with path populated. { - const dir = path.join(tmpdir.path, `mkdirp_${n++}`); + const dir = tmpdir.resolve(`mkdirp_${n++}`); fs.mkdirSync(dir); const codeExpected = makeDirectoryReadOnly(dir); fs.mkdir(path.join(dir, '/bar'), { recursive: true }, (err) => { diff --git a/test/parallel/test-fs-mkdir-rmdir.js b/test/parallel/test-fs-mkdir-rmdir.js index 738cfc0de0023b..7fa3473f1c8083 100644 --- a/test/parallel/test-fs-mkdir-rmdir.js +++ b/test/parallel/test-fs-mkdir-rmdir.js @@ -2,10 +2,9 @@ const common = require('../common'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); const tmpdir = require('../common/tmpdir'); -const d = path.join(tmpdir.path, 'dir'); +const d = tmpdir.resolve('dir'); tmpdir.refresh(); diff --git a/test/parallel/test-fs-mkdir.js b/test/parallel/test-fs-mkdir.js index c0b9d146c6f55d..95e9c56974132a 100644 --- a/test/parallel/test-fs-mkdir.js +++ b/test/parallel/test-fs-mkdir.js @@ -35,7 +35,7 @@ function nextdir() { // fs.mkdir creates directory using assigned path { - const pathname = path.join(tmpdir.path, nextdir()); + const pathname = tmpdir.resolve(nextdir()); fs.mkdir(pathname, common.mustCall(function(err) { assert.strictEqual(err, null); @@ -45,7 +45,7 @@ function nextdir() { // fs.mkdir creates directory with assigned mode value { - const pathname = path.join(tmpdir.path, nextdir()); + const pathname = tmpdir.resolve(nextdir()); fs.mkdir(pathname, 0o777, common.mustCall(function(err) { assert.strictEqual(err, null); @@ -55,7 +55,7 @@ function nextdir() { // fs.mkdir creates directory with mode passed as an options object { - const pathname = path.join(tmpdir.path, nextdir()); + const pathname = tmpdir.resolve(nextdir()); fs.mkdir(pathname, common.mustNotMutateObjectDeep({ mode: 0o777 }), common.mustCall(function(err) { assert.strictEqual(err, null); @@ -65,7 +65,7 @@ function nextdir() { // fs.mkdirSync creates directory with mode passed as an options object { - const pathname = path.join(tmpdir.path, nextdir()); + const pathname = tmpdir.resolve(nextdir()); fs.mkdirSync(pathname, common.mustNotMutateObjectDeep({ mode: 0o777 })); @@ -74,7 +74,7 @@ function nextdir() { // mkdirSync successfully creates directory from given path { - const pathname = path.join(tmpdir.path, nextdir()); + const pathname = tmpdir.resolve(nextdir()); fs.mkdirSync(pathname); @@ -103,7 +103,7 @@ function nextdir() { // mkdirpSync when both top-level, and sub-folders do not exist. { - const pathname = path.join(tmpdir.path, nextdir(), nextdir()); + const pathname = tmpdir.resolve(nextdir(), nextdir()); fs.mkdirSync(pathname, common.mustNotMutateObjectDeep({ recursive: true })); @@ -114,7 +114,7 @@ function nextdir() { // mkdirpSync when folder already exists. { - const pathname = path.join(tmpdir.path, nextdir(), nextdir()); + const pathname = tmpdir.resolve(nextdir(), nextdir()); fs.mkdirSync(pathname, { recursive: true }); // Should not cause an error. @@ -136,7 +136,7 @@ function nextdir() { // mkdirpSync when path is a file. { - const pathname = path.join(tmpdir.path, nextdir(), nextdir()); + const pathname = tmpdir.resolve(nextdir(), nextdir()); fs.mkdirSync(path.dirname(pathname)); fs.writeFileSync(pathname, '', 'utf8'); @@ -154,7 +154,7 @@ function nextdir() { // mkdirpSync when part of the path is a file. { - const filename = path.join(tmpdir.path, nextdir(), nextdir()); + const filename = tmpdir.resolve(nextdir(), nextdir()); const pathname = path.join(filename, nextdir(), nextdir()); fs.mkdirSync(path.dirname(filename)); @@ -174,7 +174,7 @@ function nextdir() { // `mkdirp` when folder does not yet exist. { - const pathname = path.join(tmpdir.path, nextdir(), nextdir()); + const pathname = tmpdir.resolve(nextdir(), nextdir()); fs.mkdir(pathname, common.mustNotMutateObjectDeep({ recursive: true }), common.mustCall(function(err) { assert.strictEqual(err, null); @@ -185,7 +185,7 @@ function nextdir() { // `mkdirp` when path is a file. { - const pathname = path.join(tmpdir.path, nextdir(), nextdir()); + const pathname = tmpdir.resolve(nextdir(), nextdir()); fs.mkdirSync(path.dirname(pathname)); fs.writeFileSync(pathname, '', 'utf8'); @@ -198,7 +198,7 @@ function nextdir() { // `mkdirp` when part of the path is a file. { - const filename = path.join(tmpdir.path, nextdir(), nextdir()); + const filename = tmpdir.resolve(nextdir(), nextdir()); const pathname = path.join(filename, nextdir(), nextdir()); fs.mkdirSync(path.dirname(filename)); @@ -218,7 +218,7 @@ function nextdir() { // mkdirpSync dirname loop // XXX: windows and smartos have issues removing a directory that you're in. if (common.isMainThread && (common.isLinux || common.isOSX)) { - const pathname = path.join(tmpdir.path, nextdir()); + const pathname = tmpdir.resolve(nextdir()); fs.mkdirSync(pathname); process.chdir(pathname); fs.rmdirSync(pathname); @@ -240,7 +240,7 @@ if (common.isMainThread && (common.isLinux || common.isOSX)) { // mkdirSync and mkdir require options.recursive to be a boolean. // Anything else generates an error. { - const pathname = path.join(tmpdir.path, nextdir()); + const pathname = tmpdir.resolve(nextdir()); ['', 1, {}, [], null, Symbol('test'), () => {}].forEach((recursive) => { const received = common.invalidArgTypeHelper(recursive); assert.throws( @@ -268,8 +268,8 @@ if (common.isMainThread && (common.isLinux || common.isOSX)) { { const dir1 = nextdir(); const dir2 = nextdir(); - const firstPathCreated = path.join(tmpdir.path, dir1); - const pathname = path.join(tmpdir.path, dir1, dir2); + const firstPathCreated = tmpdir.resolve(dir1); + const pathname = tmpdir.resolve(dir1, dir2); fs.mkdir(pathname, common.mustNotMutateObjectDeep({ recursive: true }), common.mustCall(function(err, path) { assert.strictEqual(err, null); @@ -283,8 +283,8 @@ if (common.isMainThread && (common.isLinux || common.isOSX)) { { const dir1 = nextdir(); const dir2 = nextdir(); - const pathname = path.join(tmpdir.path, dir1, dir2); - fs.mkdirSync(path.join(tmpdir.path, dir1)); + const pathname = tmpdir.resolve(dir1, dir2); + fs.mkdirSync(tmpdir.resolve(dir1)); fs.mkdir(pathname, common.mustNotMutateObjectDeep({ recursive: true }), common.mustCall(function(err, path) { assert.strictEqual(err, null); assert.strictEqual(fs.existsSync(pathname), true); @@ -297,8 +297,8 @@ if (common.isMainThread && (common.isLinux || common.isOSX)) { { const dir1 = nextdir(); const dir2 = nextdir(); - const pathname = path.join(tmpdir.path, dir1, dir2); - fs.mkdirSync(path.join(tmpdir.path, dir1, dir2), common.mustNotMutateObjectDeep({ recursive: true })); + const pathname = tmpdir.resolve(dir1, dir2); + fs.mkdirSync(tmpdir.resolve(dir1, dir2), common.mustNotMutateObjectDeep({ recursive: true })); fs.mkdir(pathname, common.mustNotMutateObjectDeep({ recursive: true }), common.mustCall(function(err, path) { assert.strictEqual(err, null); assert.strictEqual(fs.existsSync(pathname), true); @@ -311,8 +311,8 @@ if (common.isMainThread && (common.isLinux || common.isOSX)) { { const dir1 = nextdir(); const dir2 = nextdir(); - const firstPathCreated = path.join(tmpdir.path, dir1); - const pathname = path.join(tmpdir.path, dir1, dir2); + const firstPathCreated = tmpdir.resolve(dir1); + const pathname = tmpdir.resolve(dir1, dir2); const p = fs.mkdirSync(pathname, common.mustNotMutateObjectDeep({ recursive: true })); assert.strictEqual(fs.existsSync(pathname), true); assert.strictEqual(fs.statSync(pathname).isDirectory(), true); @@ -323,8 +323,8 @@ if (common.isMainThread && (common.isLinux || common.isOSX)) { { const dir1 = nextdir(); const dir2 = nextdir(); - const pathname = path.join(tmpdir.path, dir1, dir2); - fs.mkdirSync(path.join(tmpdir.path, dir1), common.mustNotMutateObjectDeep({ recursive: true })); + const pathname = tmpdir.resolve(dir1, dir2); + fs.mkdirSync(tmpdir.resolve(dir1), common.mustNotMutateObjectDeep({ recursive: true })); const p = fs.mkdirSync(pathname, common.mustNotMutateObjectDeep({ recursive: true })); assert.strictEqual(fs.existsSync(pathname), true); assert.strictEqual(fs.statSync(pathname).isDirectory(), true); @@ -335,8 +335,8 @@ if (common.isMainThread && (common.isLinux || common.isOSX)) { { const dir1 = nextdir(); const dir2 = nextdir(); - const pathname = path.join(tmpdir.path, dir1, dir2); - fs.mkdirSync(path.join(tmpdir.path, dir1, dir2), common.mustNotMutateObjectDeep({ recursive: true })); + const pathname = tmpdir.resolve(dir1, dir2); + fs.mkdirSync(tmpdir.resolve(dir1, dir2), common.mustNotMutateObjectDeep({ recursive: true })); const p = fs.mkdirSync(pathname, common.mustNotMutateObjectDeep({ recursive: true })); assert.strictEqual(fs.existsSync(pathname), true); assert.strictEqual(fs.statSync(pathname).isDirectory(), true); @@ -347,8 +347,8 @@ if (common.isMainThread && (common.isLinux || common.isOSX)) { { const dir1 = nextdir(); const dir2 = nextdir(); - const firstPathCreated = path.join(tmpdir.path, dir1); - const pathname = path.join(tmpdir.path, dir1, dir2); + const firstPathCreated = tmpdir.resolve(dir1); + const pathname = tmpdir.resolve(dir1, dir2); async function testCase() { const p = await fs.promises.mkdir(pathname, common.mustNotMutateObjectDeep({ recursive: true })); assert.strictEqual(fs.existsSync(pathname), true); diff --git a/test/parallel/test-fs-mkdtemp.js b/test/parallel/test-fs-mkdtemp.js index 9c5b952cfc9e79..e93809d5b44546 100644 --- a/test/parallel/test-fs-mkdtemp.js +++ b/test/parallel/test-fs-mkdtemp.js @@ -16,26 +16,26 @@ function handler(err, folder) { // Test with plain string { - const tmpFolder = fs.mkdtempSync(path.join(tmpdir.path, 'foo.')); + const tmpFolder = fs.mkdtempSync(tmpdir.resolve('foo.')); assert.strictEqual(path.basename(tmpFolder).length, 'foo.XXXXXX'.length); assert(fs.existsSync(tmpFolder)); - const utf8 = fs.mkdtempSync(path.join(tmpdir.path, '\u0222abc.')); + const utf8 = fs.mkdtempSync(tmpdir.resolve('\u0222abc.')); assert.strictEqual(Buffer.byteLength(path.basename(utf8)), Buffer.byteLength('\u0222abc.XXXXXX')); assert(fs.existsSync(utf8)); - fs.mkdtemp(path.join(tmpdir.path, 'bar.'), common.mustCall(handler)); + fs.mkdtemp(tmpdir.resolve('bar.'), common.mustCall(handler)); // Same test as above, but making sure that passing an options object doesn't // affect the way the callback function is handled. - fs.mkdtemp(path.join(tmpdir.path, 'bar.'), {}, common.mustCall(handler)); + fs.mkdtemp(tmpdir.resolve('bar.'), {}, common.mustCall(handler)); const warningMsg = 'mkdtemp() templates ending with X are not portable. ' + 'For details see: https://nodejs.org/api/fs.html'; common.expectWarning('Warning', warningMsg); - fs.mkdtemp(path.join(tmpdir.path, 'bar.X'), common.mustCall(handler)); + fs.mkdtemp(tmpdir.resolve('bar.X'), common.mustCall(handler)); } // Test with URL object @@ -62,46 +62,46 @@ function handler(err, folder) { // Test with Buffer { - const tmpFolder = fs.mkdtempSync(Buffer.from(path.join(tmpdir.path, 'foo.'))); + const tmpFolder = fs.mkdtempSync(Buffer.from(tmpdir.resolve('foo.'))); assert.strictEqual(path.basename(tmpFolder).length, 'foo.XXXXXX'.length); assert(fs.existsSync(tmpFolder)); - const utf8 = fs.mkdtempSync(Buffer.from(path.join(tmpdir.path, '\u0222abc.'))); + const utf8 = fs.mkdtempSync(Buffer.from(tmpdir.resolve('\u0222abc.'))); assert.strictEqual(Buffer.byteLength(path.basename(utf8)), Buffer.byteLength('\u0222abc.XXXXXX')); assert(fs.existsSync(utf8)); - fs.mkdtemp(Buffer.from(path.join(tmpdir.path, 'bar.')), common.mustCall(handler)); + fs.mkdtemp(Buffer.from(tmpdir.resolve('bar.')), common.mustCall(handler)); // Same test as above, but making sure that passing an options object doesn't // affect the way the callback function is handled. - fs.mkdtemp(Buffer.from(path.join(tmpdir.path, 'bar.')), {}, common.mustCall(handler)); + fs.mkdtemp(Buffer.from(tmpdir.resolve('bar.')), {}, common.mustCall(handler)); // Warning fires only once - fs.mkdtemp(Buffer.from(path.join(tmpdir.path, 'bar.X')), common.mustCall(handler)); + fs.mkdtemp(Buffer.from(tmpdir.resolve('bar.X')), common.mustCall(handler)); } // Test with Uint8Array { const encoder = new TextEncoder(); - const tmpFolder = fs.mkdtempSync(encoder.encode(path.join(tmpdir.path, 'foo.'))); + const tmpFolder = fs.mkdtempSync(encoder.encode(tmpdir.resolve('foo.'))); assert.strictEqual(path.basename(tmpFolder).length, 'foo.XXXXXX'.length); assert(fs.existsSync(tmpFolder)); - const utf8 = fs.mkdtempSync(encoder.encode(path.join(tmpdir.path, '\u0222abc.'))); + const utf8 = fs.mkdtempSync(encoder.encode(tmpdir.resolve('\u0222abc.'))); assert.strictEqual(Buffer.byteLength(path.basename(utf8)), Buffer.byteLength('\u0222abc.XXXXXX')); assert(fs.existsSync(utf8)); - fs.mkdtemp(encoder.encode(path.join(tmpdir.path, 'bar.')), common.mustCall(handler)); + fs.mkdtemp(encoder.encode(tmpdir.resolve('bar.')), common.mustCall(handler)); // Same test as above, but making sure that passing an options object doesn't // affect the way the callback function is handled. - fs.mkdtemp(encoder.encode(path.join(tmpdir.path, 'bar.')), {}, common.mustCall(handler)); + fs.mkdtemp(encoder.encode(tmpdir.resolve('bar.')), {}, common.mustCall(handler)); // Warning fires only once - fs.mkdtemp(encoder.encode(path.join(tmpdir.path, 'bar.X')), common.mustCall(handler)); + fs.mkdtemp(encoder.encode(tmpdir.resolve('bar.X')), common.mustCall(handler)); } diff --git a/test/parallel/test-fs-non-number-arguments-throw.js b/test/parallel/test-fs-non-number-arguments-throw.js index a0d533667b3c1f..dbcec683cda0a1 100644 --- a/test/parallel/test-fs-non-number-arguments-throw.js +++ b/test/parallel/test-fs-non-number-arguments-throw.js @@ -3,9 +3,8 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); const tmpdir = require('../common/tmpdir'); -const tempFile = path.join(tmpdir.path, 'fs-non-number-arguments-throw'); +const tempFile = tmpdir.resolve('fs-non-number-arguments-throw'); tmpdir.refresh(); fs.writeFileSync(tempFile, 'abc\ndef'); diff --git a/test/parallel/test-fs-open-flags.js b/test/parallel/test-fs-open-flags.js index 2b2bba64aec91d..bf00ec3308268a 100644 --- a/test/parallel/test-fs-open-flags.js +++ b/test/parallel/test-fs-open-flags.js @@ -27,7 +27,6 @@ const fixtures = require('../common/fixtures'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); // 0 if not found in fs.constants const { O_APPEND = 0, @@ -86,7 +85,7 @@ assert.throws( if (common.isLinux || common.isOSX) { const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); - const file = path.join(tmpdir.path, 'a.js'); + const file = tmpdir.resolve('a.js'); fs.copyFileSync(fixtures.path('a.js'), file); fs.open(file, O_DSYNC, common.mustSucceed((fd) => { fs.closeSync(fd); diff --git a/test/parallel/test-fs-open-mode-mask.js b/test/parallel/test-fs-open-mode-mask.js index bab89f98f0d1a7..a79591c0aea863 100644 --- a/test/parallel/test-fs-open-mode-mask.js +++ b/test/parallel/test-fs-open-mode-mask.js @@ -4,7 +4,6 @@ const common = require('../common'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); const mode = common.isWindows ? 0o444 : 0o644; @@ -20,7 +19,7 @@ function test(mode, asString) { (mode | maskToIgnore).toString(8) : (mode | maskToIgnore); { - const file = path.join(tmpdir.path, `openSync-${suffix}.txt`); + const file = tmpdir.resolve(`openSync-${suffix}.txt`); const fd = fs.openSync(file, 'w+', input); assert.strictEqual(fs.fstatSync(fd).mode & 0o777, mode); fs.closeSync(fd); @@ -28,7 +27,7 @@ function test(mode, asString) { } { - const file = path.join(tmpdir.path, `open-${suffix}.txt`); + const file = tmpdir.resolve(`open-${suffix}.txt`); fs.open(file, 'w+', input, common.mustSucceed((fd) => { assert.strictEqual(fs.fstatSync(fd).mode & 0o777, mode); fs.closeSync(fd); diff --git a/test/parallel/test-fs-open-numeric-flags.js b/test/parallel/test-fs-open-numeric-flags.js index 0e5ab6997e3342..3237b2764e39b0 100644 --- a/test/parallel/test-fs-open-numeric-flags.js +++ b/test/parallel/test-fs-open-numeric-flags.js @@ -3,13 +3,12 @@ require('../common'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); // O_WRONLY without O_CREAT shall fail with ENOENT -const pathNE = path.join(tmpdir.path, 'file-should-not-exist'); +const pathNE = tmpdir.resolve('file-should-not-exist'); assert.throws( () => fs.openSync(pathNE, fs.constants.O_WRONLY), (e) => e.code === 'ENOENT' diff --git a/test/parallel/test-fs-options-immutable.js b/test/parallel/test-fs-options-immutable.js index dfe05a96ef7c3b..fffdecdc87cf18 100644 --- a/test/parallel/test-fs-options-immutable.js +++ b/test/parallel/test-fs-options-immutable.js @@ -7,7 +7,6 @@ const common = require('../common'); // Refer: https://github.com/nodejs/node/issues/7655 const fs = require('fs'); -const path = require('path'); const options = common.mustNotMutateObjectDeep({}); const tmpdir = require('../common/tmpdir'); @@ -20,8 +19,8 @@ fs.readdir(__dirname, options, common.mustSucceed()); fs.readdirSync(__dirname, options); if (common.canCreateSymLink()) { - const sourceFile = path.resolve(tmpdir.path, 'test-readlink'); - const linkFile = path.resolve(tmpdir.path, 'test-readlink-link'); + const sourceFile = tmpdir.resolve('test-readlink'); + const linkFile = tmpdir.resolve('test-readlink-link'); fs.writeFileSync(sourceFile, ''); fs.symlinkSync(sourceFile, linkFile); @@ -31,13 +30,13 @@ if (common.canCreateSymLink()) { } { - const fileName = path.resolve(tmpdir.path, 'writeFile'); + const fileName = tmpdir.resolve('writeFile'); fs.writeFileSync(fileName, 'ABCD', options); fs.writeFile(fileName, 'ABCD', options, common.mustSucceed()); } { - const fileName = path.resolve(tmpdir.path, 'appendFile'); + const fileName = tmpdir.resolve('appendFile'); fs.appendFileSync(fileName, 'ABCD', options); fs.appendFile(fileName, 'ABCD', options, common.mustSucceed()); } @@ -58,13 +57,13 @@ if (!common.isIBMi) { // IBMi does not support fs.watch() } { - const tempFileName = path.resolve(tmpdir.path, 'mkdtemp-'); + const tempFileName = tmpdir.resolve('mkdtemp-'); fs.mkdtempSync(tempFileName, options); fs.mkdtemp(tempFileName, options, common.mustSucceed()); } { - const fileName = path.resolve(tmpdir.path, 'streams'); + const fileName = tmpdir.resolve('streams'); fs.WriteStream(fileName, options).once('open', common.mustCall(() => { fs.ReadStream(fileName, options).destroy(); })).end(); diff --git a/test/parallel/test-fs-promisified.js b/test/parallel/test-fs-promisified.js index 0744f62fd17fa5..63430f64a876d1 100644 --- a/test/parallel/test-fs-promisified.js +++ b/test/parallel/test-fs-promisified.js @@ -2,7 +2,6 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); const { promisify } = require('util'); const read = promisify(fs.read); @@ -21,7 +20,7 @@ const exists = promisify(fs.exists); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); { - const filename = path.join(tmpdir.path, 'write-promise.txt'); + const filename = tmpdir.resolve('write-promise.txt'); const fd = fs.openSync(filename, 'w'); write(fd, Buffer.from('foobar')).then(common.mustCall((obj) => { assert.strictEqual(typeof obj.bytesWritten, 'number'); diff --git a/test/parallel/test-fs-rm.js b/test/parallel/test-fs-rm.js index 93f59544a87e99..4ab06421c3f1ce 100644 --- a/test/parallel/test-fs-rm.js +++ b/test/parallel/test-fs-rm.js @@ -14,7 +14,7 @@ tmpdir.refresh(); let count = 0; const nextDirPath = (name = 'rm') => - path.join(tmpdir.path, `${name}-${count++}`); + tmpdir.resolve(`${name}-${count++}`); const isGitPresent = (() => { try { execSync('git --version'); return true; } catch { return false; } @@ -128,7 +128,7 @@ function removeAsync(dir) { // Should fail if target does not exist fs.rm( - path.join(tmpdir.path, 'noexist.txt'), + tmpdir.resolve('noexist.txt'), common.mustNotMutateObjectDeep({ recursive: true }), common.mustCall((err) => { assert.strictEqual(err.code, 'ENOENT'); @@ -136,7 +136,7 @@ function removeAsync(dir) { ); // Should delete a file - const filePath = path.join(tmpdir.path, 'rm-async-file.txt'); + const filePath = tmpdir.resolve('rm-async-file.txt'); fs.writeFileSync(filePath, ''); fs.rm(filePath, common.mustNotMutateObjectDeep({ recursive: true }), common.mustCall((err) => { try { @@ -148,9 +148,9 @@ function removeAsync(dir) { })); // Should delete a valid symlink - const linkTarget = path.join(tmpdir.path, 'link-target-async.txt'); + const linkTarget = tmpdir.resolve('link-target-async.txt'); fs.writeFileSync(linkTarget, ''); - const validLink = path.join(tmpdir.path, 'valid-link-async'); + const validLink = tmpdir.resolve('valid-link-async'); fs.symlinkSync(linkTarget, validLink); fs.rm(validLink, common.mustNotMutateObjectDeep({ recursive: true }), common.mustCall((err) => { try { @@ -163,7 +163,7 @@ function removeAsync(dir) { })); // Should delete an invalid symlink - const invalidLink = path.join(tmpdir.path, 'invalid-link-async'); + const invalidLink = tmpdir.resolve('invalid-link-async'); fs.symlinkSync('definitely-does-not-exist-async', invalidLink); fs.rm(invalidLink, common.mustNotMutateObjectDeep({ recursive: true }), common.mustCall((err) => { try { @@ -175,8 +175,8 @@ function removeAsync(dir) { })); // Should delete a symlink that is part of a loop - const loopLinkA = path.join(tmpdir.path, 'loop-link-async-a'); - const loopLinkB = path.join(tmpdir.path, 'loop-link-async-b'); + const loopLinkA = tmpdir.resolve('loop-link-async-a'); + const loopLinkB = tmpdir.resolve('loop-link-async-b'); fs.symlinkSync(loopLinkA, loopLinkB); fs.symlinkSync(loopLinkB, loopLinkA); fs.rm(loopLinkA, common.mustNotMutateObjectDeep({ recursive: true }), common.mustCall((err) => { @@ -215,7 +215,7 @@ if (isGitPresent) { // Should fail if target does not exist assert.throws(() => { - fs.rmSync(path.join(tmpdir.path, 'noexist.txt'), common.mustNotMutateObjectDeep({ recursive: true })); + fs.rmSync(tmpdir.resolve('noexist.txt'), common.mustNotMutateObjectDeep({ recursive: true })); }, { code: 'ENOENT', name: 'Error', @@ -223,7 +223,7 @@ if (isGitPresent) { }); // Should delete a file - const filePath = path.join(tmpdir.path, 'rm-file.txt'); + const filePath = tmpdir.resolve('rm-file.txt'); fs.writeFileSync(filePath, ''); try { @@ -234,9 +234,9 @@ if (isGitPresent) { } // Should delete a valid symlink - const linkTarget = path.join(tmpdir.path, 'link-target.txt'); + const linkTarget = tmpdir.resolve('link-target.txt'); fs.writeFileSync(linkTarget, ''); - const validLink = path.join(tmpdir.path, 'valid-link'); + const validLink = tmpdir.resolve('valid-link'); fs.symlinkSync(linkTarget, validLink); try { fs.rmSync(validLink); @@ -247,7 +247,7 @@ if (isGitPresent) { } // Should delete an invalid symlink - const invalidLink = path.join(tmpdir.path, 'invalid-link'); + const invalidLink = tmpdir.resolve('invalid-link'); fs.symlinkSync('definitely-does-not-exist', invalidLink); try { fs.rmSync(invalidLink); @@ -257,8 +257,8 @@ if (isGitPresent) { } // Should delete a symlink that is part of a loop - const loopLinkA = path.join(tmpdir.path, 'loop-link-a'); - const loopLinkB = path.join(tmpdir.path, 'loop-link-b'); + const loopLinkA = tmpdir.resolve('loop-link-a'); + const loopLinkB = tmpdir.resolve('loop-link-b'); fs.symlinkSync(loopLinkA, loopLinkB); fs.symlinkSync(loopLinkB, loopLinkA); try { @@ -317,7 +317,7 @@ if (isGitPresent) { // Should fail if target does not exist await assert.rejects(fs.promises.rm( - path.join(tmpdir.path, 'noexist.txt'), + tmpdir.resolve('noexist.txt'), { recursive: true } ), { code: 'ENOENT', @@ -326,10 +326,10 @@ if (isGitPresent) { }); // Should not fail if target does not exist and force option is true - await fs.promises.rm(path.join(tmpdir.path, 'noexist.txt'), common.mustNotMutateObjectDeep({ force: true })); + await fs.promises.rm(tmpdir.resolve('noexist.txt'), common.mustNotMutateObjectDeep({ force: true })); // Should delete file - const filePath = path.join(tmpdir.path, 'rm-promises-file.txt'); + const filePath = tmpdir.resolve('rm-promises-file.txt'); fs.writeFileSync(filePath, ''); try { @@ -340,9 +340,9 @@ if (isGitPresent) { } // Should delete a valid symlink - const linkTarget = path.join(tmpdir.path, 'link-target-prom.txt'); + const linkTarget = tmpdir.resolve('link-target-prom.txt'); fs.writeFileSync(linkTarget, ''); - const validLink = path.join(tmpdir.path, 'valid-link-prom'); + const validLink = tmpdir.resolve('valid-link-prom'); fs.symlinkSync(linkTarget, validLink); try { await fs.promises.rm(validLink); @@ -353,7 +353,7 @@ if (isGitPresent) { } // Should delete an invalid symlink - const invalidLink = path.join(tmpdir.path, 'invalid-link-prom'); + const invalidLink = tmpdir.resolve('invalid-link-prom'); fs.symlinkSync('definitely-does-not-exist-prom', invalidLink); try { await fs.promises.rm(invalidLink); @@ -363,8 +363,8 @@ if (isGitPresent) { } // Should delete a symlink that is part of a loop - const loopLinkA = path.join(tmpdir.path, 'loop-link-prom-a'); - const loopLinkB = path.join(tmpdir.path, 'loop-link-prom-b'); + const loopLinkA = tmpdir.resolve('loop-link-prom-a'); + const loopLinkB = tmpdir.resolve('loop-link-prom-b'); fs.symlinkSync(loopLinkA, loopLinkB); fs.symlinkSync(loopLinkB, loopLinkA); try { @@ -402,7 +402,7 @@ if (isGitPresent) { { const dir = nextDirPath(); makeNonEmptyDirectory(4, 10, 2, dir, true); - const filePath = (path.join(tmpdir.path, 'rm-args-file.txt')); + const filePath = (tmpdir.resolve('rm-args-file.txt')); fs.writeFileSync(filePath, ''); const defaults = { diff --git a/test/parallel/test-fs-rmdir-recursive-sync-warns-not-found.js b/test/parallel/test-fs-rmdir-recursive-sync-warns-not-found.js index 64ae85a0496ff7..fef68048dec1f4 100644 --- a/test/parallel/test-fs-rmdir-recursive-sync-warns-not-found.js +++ b/test/parallel/test-fs-rmdir-recursive-sync-warns-not-found.js @@ -3,7 +3,6 @@ const common = require('../common'); const tmpdir = require('../common/tmpdir'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); tmpdir.refresh(); @@ -16,7 +15,7 @@ tmpdir.refresh(); 'DEP0147' ); assert.throws( - () => fs.rmdirSync(path.join(tmpdir.path, 'noexist.txt'), + () => fs.rmdirSync(tmpdir.resolve('noexist.txt'), { recursive: true }), { code: 'ENOENT' } ); diff --git a/test/parallel/test-fs-rmdir-recursive-sync-warns-on-file.js b/test/parallel/test-fs-rmdir-recursive-sync-warns-on-file.js index 197a9cfbc711f6..b3919020063c86 100644 --- a/test/parallel/test-fs-rmdir-recursive-sync-warns-on-file.js +++ b/test/parallel/test-fs-rmdir-recursive-sync-warns-on-file.js @@ -3,7 +3,6 @@ const common = require('../common'); const tmpdir = require('../common/tmpdir'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); tmpdir.refresh(); @@ -14,7 +13,7 @@ tmpdir.refresh(); 'will be removed. Use fs.rm(path, { recursive: true }) instead', 'DEP0147' ); - const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt'); + const filePath = tmpdir.resolve('rmdir-recursive.txt'); fs.writeFileSync(filePath, ''); assert.throws( () => fs.rmdirSync(filePath, { recursive: true }), diff --git a/test/parallel/test-fs-rmdir-recursive-throws-not-found.js b/test/parallel/test-fs-rmdir-recursive-throws-not-found.js index 530f561f131d33..d984fef80e9fdd 100644 --- a/test/parallel/test-fs-rmdir-recursive-throws-not-found.js +++ b/test/parallel/test-fs-rmdir-recursive-throws-not-found.js @@ -3,14 +3,13 @@ const common = require('../common'); const tmpdir = require('../common/tmpdir'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); tmpdir.refresh(); { assert.throws( () => - fs.rmdirSync(path.join(tmpdir.path, 'noexist.txt'), { recursive: true }), + fs.rmdirSync(tmpdir.resolve('noexist.txt'), { recursive: true }), { code: 'ENOENT', } @@ -18,7 +17,7 @@ tmpdir.refresh(); } { fs.rmdir( - path.join(tmpdir.path, 'noexist.txt'), + tmpdir.resolve('noexist.txt'), { recursive: true }, common.mustCall((err) => { assert.strictEqual(err.code, 'ENOENT'); @@ -27,7 +26,7 @@ tmpdir.refresh(); } { assert.rejects( - () => fs.promises.rmdir(path.join(tmpdir.path, 'noexist.txt'), + () => fs.promises.rmdir(tmpdir.resolve('noexist.txt'), { recursive: true }), { code: 'ENOENT', diff --git a/test/parallel/test-fs-rmdir-recursive-throws-on-file.js b/test/parallel/test-fs-rmdir-recursive-throws-on-file.js index bf91bb676e2ac7..ff67cf536829b4 100644 --- a/test/parallel/test-fs-rmdir-recursive-throws-on-file.js +++ b/test/parallel/test-fs-rmdir-recursive-throws-on-file.js @@ -3,26 +3,25 @@ const common = require('../common'); const tmpdir = require('../common/tmpdir'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); tmpdir.refresh(); const code = common.isWindows ? 'ENOENT' : 'ENOTDIR'; { - const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt'); + const filePath = tmpdir.resolve('rmdir-recursive.txt'); fs.writeFileSync(filePath, ''); assert.throws(() => fs.rmdirSync(filePath, { recursive: true }), { code }); } { - const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt'); + const filePath = tmpdir.resolve('rmdir-recursive.txt'); fs.writeFileSync(filePath, ''); fs.rmdir(filePath, { recursive: true }, common.mustCall((err) => { assert.strictEqual(err.code, code); })); } { - const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt'); + const filePath = tmpdir.resolve('rmdir-recursive.txt'); fs.writeFileSync(filePath, ''); assert.rejects(() => fs.promises.rmdir(filePath, { recursive: true }), { code }).then(common.mustCall()); diff --git a/test/parallel/test-fs-rmdir-recursive-warns-not-found.js b/test/parallel/test-fs-rmdir-recursive-warns-not-found.js index 2c62f3de8141fe..86bd27aa9ec5dd 100644 --- a/test/parallel/test-fs-rmdir-recursive-warns-not-found.js +++ b/test/parallel/test-fs-rmdir-recursive-warns-not-found.js @@ -2,7 +2,6 @@ const common = require('../common'); const tmpdir = require('../common/tmpdir'); const fs = require('fs'); -const path = require('path'); tmpdir.refresh(); @@ -15,7 +14,7 @@ tmpdir.refresh(); 'DEP0147' ); fs.rmdir( - path.join(tmpdir.path, 'noexist.txt'), + tmpdir.resolve('noexist.txt'), { recursive: true }, common.mustCall() ); diff --git a/test/parallel/test-fs-rmdir-recursive-warns-on-file.js b/test/parallel/test-fs-rmdir-recursive-warns-on-file.js index bb5460792c54ea..86cb69829a86ac 100644 --- a/test/parallel/test-fs-rmdir-recursive-warns-on-file.js +++ b/test/parallel/test-fs-rmdir-recursive-warns-on-file.js @@ -3,7 +3,6 @@ const common = require('../common'); const tmpdir = require('../common/tmpdir'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); tmpdir.refresh(); @@ -14,7 +13,7 @@ tmpdir.refresh(); 'will be removed. Use fs.rm(path, { recursive: true }) instead', 'DEP0147' ); - const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt'); + const filePath = tmpdir.resolve('rmdir-recursive.txt'); fs.writeFileSync(filePath, ''); fs.rmdir(filePath, { recursive: true }, common.mustCall((err) => { assert.strictEqual(err.code, common.isWindows ? 'ENOENT' : 'ENOTDIR'); diff --git a/test/parallel/test-fs-rmdir-recursive.js b/test/parallel/test-fs-rmdir-recursive.js index 1359f50cfbb49c..f98376488edee7 100644 --- a/test/parallel/test-fs-rmdir-recursive.js +++ b/test/parallel/test-fs-rmdir-recursive.js @@ -18,7 +18,7 @@ tmpdir.refresh(); let count = 0; const nextDirPath = (name = 'rmdir-recursive') => - path.join(tmpdir.path, `${name}-${count++}`); + tmpdir.resolve(`${name}-${count++}`); function makeNonEmptyDirectory(depth, files, folders, dirname, createSymLinks) { fs.mkdirSync(dirname, { recursive: true }); diff --git a/test/parallel/test-fs-stat-bigint.js b/test/parallel/test-fs-stat-bigint.js index c85e7defac2972..d1bddaa48c66f8 100644 --- a/test/parallel/test-fs-stat-bigint.js +++ b/test/parallel/test-fs-stat-bigint.js @@ -4,7 +4,6 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); const promiseFs = require('fs').promises; -const path = require('path'); const tmpdir = require('../common/tmpdir'); const { isDate } = require('util').types; const { inspect } = require('util'); @@ -14,7 +13,7 @@ tmpdir.refresh(); let testIndex = 0; function getFilename() { - const filename = path.join(tmpdir.path, `test-file-${++testIndex}`); + const filename = tmpdir.resolve(`test-file-${++testIndex}`); fs.writeFileSync(filename, 'test'); return filename; } diff --git a/test/parallel/test-fs-stat-date.mjs b/test/parallel/test-fs-stat-date.mjs index 71cdb1a40f986b..5f85bff2731e86 100644 --- a/test/parallel/test-fs-stat-date.mjs +++ b/test/parallel/test-fs-stat-date.mjs @@ -4,7 +4,6 @@ import * as common from '../common/index.mjs'; import fs from 'node:fs'; import fsPromises from 'node:fs/promises'; -import path from 'node:path'; import assert from 'node:assert'; import tmpdir from '../common/tmpdir.js'; @@ -13,7 +12,7 @@ import tmpdir from '../common/tmpdir.js'; const ignoredErrors = new Set(['EINVAL', 'EOVERFLOW']); tmpdir.refresh(); -const filepath = path.resolve(tmpdir.path, 'timestamp'); +const filepath = tmpdir.resolve('timestamp'); await (await fsPromises.open(filepath, 'w')).close(); diff --git a/test/parallel/test-fs-stream-fs-options.js b/test/parallel/test-fs-stream-fs-options.js index 65144c0d617e9b..4e4d17391e070e 100644 --- a/test/parallel/test-fs-stream-fs-options.js +++ b/test/parallel/test-fs-stream-fs-options.js @@ -2,7 +2,6 @@ require('../common'); const fixtures = require('../common/fixtures'); -const path = require('path'); const fs = require('fs'); const assert = require('assert'); @@ -15,7 +14,7 @@ const readStreamOptions = [...streamOpts, 'read']; const originalFs = { fs }; { - const file = path.join(tmpdir.path, 'write-end-test0.txt'); + const file = tmpdir.resolve('write-end-test0.txt'); writeStreamOptions.forEach((fn) => { const overrideFs = Object.assign({}, originalFs.fs, { [fn]: null }); @@ -37,7 +36,7 @@ const originalFs = { fs }; } { - const file = path.join(tmpdir.path, 'write-end-test0.txt'); + const file = tmpdir.resolve('write-end-test0.txt'); const overrideFs = Object.assign({}, originalFs.fs, { writev: 'not a fn' }); const opts = { fs: overrideFs diff --git a/test/parallel/test-fs-symlink-buffer-path.js b/test/parallel/test-fs-symlink-buffer-path.js index 8cc9571258ed14..ecad001d5ef152 100644 --- a/test/parallel/test-fs-symlink-buffer-path.js +++ b/test/parallel/test-fs-symlink-buffer-path.js @@ -27,7 +27,6 @@ if (!common.canCreateSymLink()) const fixtures = require('../common/fixtures'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); const tmpdir = require('../common/tmpdir'); @@ -35,7 +34,7 @@ tmpdir.refresh(); // Test creating and reading symbolic link const linkData = fixtures.path('/cycles/root.js'); -const linkPath = path.join(tmpdir.path, 'symlink1.js'); +const linkPath = tmpdir.resolve('symlink1.js'); let linkTime; let fileTime; diff --git a/test/parallel/test-fs-symlink-dir-junction-relative.js b/test/parallel/test-fs-symlink-dir-junction-relative.js index ec86f84b666e67..01ef8c8bdc1cf6 100644 --- a/test/parallel/test-fs-symlink-dir-junction-relative.js +++ b/test/parallel/test-fs-symlink-dir-junction-relative.js @@ -25,13 +25,12 @@ const common = require('../common'); const fixtures = require('../common/fixtures'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); const tmpdir = require('../common/tmpdir'); -const linkPath1 = path.join(tmpdir.path, 'junction1'); -const linkPath2 = path.join(tmpdir.path, 'junction2'); +const linkPath1 = tmpdir.resolve('junction1'); +const linkPath2 = tmpdir.resolve('junction2'); const linkTarget = fixtures.fixturesDir; const linkData = fixtures.fixturesDir; diff --git a/test/parallel/test-fs-symlink-dir-junction.js b/test/parallel/test-fs-symlink-dir-junction.js index f705f0e43acfcc..3990467c6f8008 100644 --- a/test/parallel/test-fs-symlink-dir-junction.js +++ b/test/parallel/test-fs-symlink-dir-junction.js @@ -23,14 +23,13 @@ const common = require('../common'); const fixtures = require('../common/fixtures'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); const tmpdir = require('../common/tmpdir'); // Test creating and reading symbolic link const linkData = fixtures.path('cycles/'); -const linkPath = path.join(tmpdir.path, 'cycles_link'); +const linkPath = tmpdir.resolve('cycles_link'); tmpdir.refresh(); @@ -52,7 +51,7 @@ fs.symlink(linkData, linkPath, 'junction', common.mustSucceed(() => { // Test invalid symlink { const linkData = fixtures.path('/not/exists/dir'); - const linkPath = path.join(tmpdir.path, 'invalid_junction_link'); + const linkPath = tmpdir.resolve('invalid_junction_link'); fs.symlink(linkData, linkPath, 'junction', common.mustSucceed(() => { assert(!fs.existsSync(linkPath)); diff --git a/test/parallel/test-fs-symlink-dir.js b/test/parallel/test-fs-symlink-dir.js index 7ce3039d4aa150..690e3302ed99cc 100644 --- a/test/parallel/test-fs-symlink-dir.js +++ b/test/parallel/test-fs-symlink-dir.js @@ -19,11 +19,11 @@ tmpdir.refresh(); const linkTargets = [ 'relative-target', - path.join(tmpdir.path, 'absolute-target'), + tmpdir.resolve('absolute-target'), ]; const linkPaths = [ - path.relative(process.cwd(), path.join(tmpdir.path, 'relative-path')), - path.join(tmpdir.path, 'absolute-path'), + path.relative(process.cwd(), tmpdir.resolve('relative-path')), + tmpdir.resolve('absolute-path'), ]; function testSync(target, path) { @@ -43,7 +43,7 @@ async function testPromises(target, path) { } for (const linkTarget of linkTargets) { - fs.mkdirSync(path.resolve(tmpdir.path, linkTarget)); + fs.mkdirSync(tmpdir.resolve(linkTarget)); for (const linkPath of linkPaths) { testSync(linkTarget, `${linkPath}-${path.basename(linkTarget)}-sync`); testAsync(linkTarget, `${linkPath}-${path.basename(linkTarget)}-async`); diff --git a/test/parallel/test-fs-symlink.js b/test/parallel/test-fs-symlink.js index 836dfeae17016c..ad4d6d1410d694 100644 --- a/test/parallel/test-fs-symlink.js +++ b/test/parallel/test-fs-symlink.js @@ -26,7 +26,6 @@ if (!common.canCreateSymLink()) common.skip('insufficient privileges'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); let linkTime; @@ -37,7 +36,7 @@ tmpdir.refresh(); // Test creating and reading symbolic link const linkData = fixtures.path('/cycles/root.js'); -const linkPath = path.join(tmpdir.path, 'symlink1.js'); +const linkPath = tmpdir.resolve('symlink1.js'); fs.symlink(linkData, linkPath, common.mustSucceed(() => { fs.lstat(linkPath, common.mustSucceed((stats) => { @@ -56,7 +55,7 @@ fs.symlink(linkData, linkPath, common.mustSucceed(() => { // Test invalid symlink { const linkData = fixtures.path('/not/exists/file'); - const linkPath = path.join(tmpdir.path, 'symlink2.js'); + const linkPath = tmpdir.resolve('symlink2.js'); fs.symlink(linkData, linkPath, common.mustSucceed(() => { assert(!fs.existsSync(linkPath)); diff --git a/test/parallel/test-fs-utils-get-dirents.js b/test/parallel/test-fs-utils-get-dirents.js index 0cc6cd40243f19..9c53a4146a6768 100644 --- a/test/parallel/test-fs-utils-get-dirents.js +++ b/test/parallel/test-fs-utils-get-dirents.js @@ -7,7 +7,6 @@ const assert = require('assert'); const { internalBinding } = require('internal/test/binding'); const { UV_DIRENT_UNKNOWN } = internalBinding('constants').fs; const fs = require('fs'); -const path = require('path'); const tmpdir = require('../common/tmpdir'); const filename = 'foo'; @@ -15,7 +14,7 @@ const filename = 'foo'; { // setup tmpdir.refresh(); - fs.writeFileSync(path.join(tmpdir.path, filename), ''); + fs.writeFileSync(tmpdir.resolve(filename), ''); } // getDirents { diff --git a/test/parallel/test-fs-watch-close-when-destroyed.js b/test/parallel/test-fs-watch-close-when-destroyed.js index d185599ee96a23..afa5307e4d1ca5 100644 --- a/test/parallel/test-fs-watch-close-when-destroyed.js +++ b/test/parallel/test-fs-watch-close-when-destroyed.js @@ -17,10 +17,9 @@ if (common.isIBMi) const tmpdir = require('../common/tmpdir'); const fs = require('fs'); -const path = require('path'); tmpdir.refresh(); -const root = path.join(tmpdir.path, 'watched-directory'); +const root = tmpdir.resolve('watched-directory'); fs.mkdirSync(root); const watcher = fs.watch(root, { persistent: false, recursive: false }); diff --git a/test/parallel/test-fs-watch-encoding.js b/test/parallel/test-fs-watch-encoding.js index 0ef0881a6b5142..758c6c26be27b8 100644 --- a/test/parallel/test-fs-watch-encoding.js +++ b/test/parallel/test-fs-watch-encoding.js @@ -23,13 +23,12 @@ if (common.isIBMi) common.skip('IBMi does not support `fs.watch()`'); const fs = require('fs'); -const path = require('path'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); const fn = '新建文夹件.txt'; -const a = path.join(tmpdir.path, fn); +const a = tmpdir.resolve(fn); const watchers = new Set(); diff --git a/test/parallel/test-fs-watch-enoent.js b/test/parallel/test-fs-watch-enoent.js index 0d5bfc97315d0e..43bcc647749f07 100644 --- a/test/parallel/test-fs-watch-enoent.js +++ b/test/parallel/test-fs-watch-enoent.js @@ -11,8 +11,7 @@ if (common.isIBMi) const assert = require('assert'); const fs = require('fs'); const tmpdir = require('../common/tmpdir'); -const path = require('path'); -const nonexistentFile = path.join(tmpdir.path, 'non-existent'); +const nonexistentFile = tmpdir.resolve('non-existent'); const { internalBinding } = require('internal/test/binding'); const { UV_ENODEV, @@ -48,7 +47,7 @@ tmpdir.refresh(); { if (common.isOSX || common.isWindows) { - const file = path.join(tmpdir.path, 'file-to-watch'); + const file = tmpdir.resolve('file-to-watch'); fs.writeFileSync(file, 'test'); const watcher = fs.watch(file, common.mustNotCall()); diff --git a/test/parallel/test-fs-watch-file-enoent-after-deletion.js b/test/parallel/test-fs-watch-file-enoent-after-deletion.js index 6eaa4c68c58bc8..e4baf90fd17b94 100644 --- a/test/parallel/test-fs-watch-file-enoent-after-deletion.js +++ b/test/parallel/test-fs-watch-file-enoent-after-deletion.js @@ -32,13 +32,12 @@ const common = require('../common'); // stopped it from getting emitted. // https://github.com/nodejs/node-v0.x-archive/issues/4027 -const path = require('path'); const fs = require('fs'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -const filename = path.join(tmpdir.path, 'watched'); +const filename = tmpdir.resolve('watched'); fs.writeFileSync(filename, 'quis custodiet ipsos custodes'); fs.watchFile(filename, { interval: 50 }, common.mustCall(function(curr, prev) { diff --git a/test/parallel/test-fs-watch.js b/test/parallel/test-fs-watch.js index 479cc2b3e293e2..2c6386a2d118b6 100644 --- a/test/parallel/test-fs-watch.js +++ b/test/parallel/test-fs-watch.js @@ -17,7 +17,7 @@ class WatchTestCase { this.field = field; this.shouldSkip = !shouldInclude; } - get dirPath() { return join(tmpdir.path, this.dirName); } + get dirPath() { return tmpdir.resolve(this.dirName); } get filePath() { return join(this.dirPath, this.fileName); } } diff --git a/test/parallel/test-fs-watchfile-bigint.js b/test/parallel/test-fs-watchfile-bigint.js index 0f462947a7799d..49b7aa1057ab07 100644 --- a/test/parallel/test-fs-watchfile-bigint.js +++ b/test/parallel/test-fs-watchfile-bigint.js @@ -7,11 +7,10 @@ const common = require('../common'); const assert = require('assert'); const { BigIntStats } = require('internal/fs/utils'); const fs = require('fs'); -const path = require('path'); const tmpdir = require('../common/tmpdir'); -const enoentFile = path.join(tmpdir.path, 'non-existent-file'); +const enoentFile = tmpdir.resolve('non-existent-file'); const expectedStatObject = new BigIntStats( 0n, // dev 0n, // mode diff --git a/test/parallel/test-fs-watchfile.js b/test/parallel/test-fs-watchfile.js index 4a94b16f9b63f2..966876b6787046 100644 --- a/test/parallel/test-fs-watchfile.js +++ b/test/parallel/test-fs-watchfile.js @@ -30,7 +30,7 @@ assert.throws(() => { fs.watchFile(new Object(), common.mustNotCall()); }, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' }); -const enoentFile = path.join(tmpdir.path, 'non-existent-file'); +const enoentFile = tmpdir.resolve('non-existent-file'); const expectedStatObject = new fs.Stats( 0, // dev 0, // mode @@ -85,7 +85,7 @@ watcher.on('stop', common.mustCall()); // Watch events should callback with a filename on supported systems. // Omitting AIX. It works but not reliably. if (common.isLinux || common.isOSX || common.isWindows) { - const dir = path.join(tmpdir.path, 'watch'); + const dir = tmpdir.resolve('watch'); fs.mkdir(dir, common.mustCall(function(err) { if (err) assert.fail(err);