diff --git a/test/common/v8-max-heap-size-option.js b/test/common/v8-max-heap-size-option.js index 4487b011a97c..250cb72df944 100644 --- a/test/common/v8-max-heap-size-option.js +++ b/test/common/v8-max-heap-size-option.js @@ -2,7 +2,6 @@ const assert = require('assert'); const { spawnSync } = require('child_process'); -const path = require('path'); const fs = require('fs'); const tmpdir = require('./tmpdir'); @@ -14,7 +13,7 @@ const testScript = ` `; tmpdir.refresh(); -const scriptPath = path.join(tmpdir.path, 'heap-limit-test.js'); +const scriptPath = tmpdir.resolve('heap-limit-test.js'); fs.writeFileSync(scriptPath, testScript); const child = spawnSync( diff --git a/test/known_issues/test-fs-cp-async-buffer.js b/test/known_issues/test-fs-cp-async-buffer.js index 4cbf02414749..5fecd82ae160 100644 --- a/test/known_issues/test-fs-cp-async-buffer.js +++ b/test/known_issues/test-fs-cp-async-buffer.js @@ -8,13 +8,12 @@ const common = require('../common'); const { mkdirSync, promises } = require('fs'); -const { join } = require('path'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -const tmpA = join(tmpdir.path, 'a'); -const tmpB = join(tmpdir.path, 'b'); +const tmpA = tmpdir.resolve('a'); +const tmpB = tmpdir.resolve('b'); mkdirSync(tmpA, { recursive: true }); diff --git a/test/known_issues/test-fs-cp-filter.js b/test/known_issues/test-fs-cp-filter.js index 334ade532b33..035109f2144c 100644 --- a/test/known_issues/test-fs-cp-filter.js +++ b/test/known_issues/test-fs-cp-filter.js @@ -20,9 +20,9 @@ const { const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -const pathA = join(tmpdir.path, 'a'); +const pathA = tmpdir.resolve('a'); const pathAC = join(pathA, 'c'); -const pathB = join(tmpdir.path, 'b'); +const pathB = tmpdir.resolve('b'); mkdirSync(pathAC, { recursive: true }); cpSync(Buffer.from(pathA), Buffer.from(pathB), { diff --git a/test/known_issues/test-fs-cp-non-utf8.js b/test/known_issues/test-fs-cp-non-utf8.js index 814859be8ea6..4829886fc25d 100644 --- a/test/known_issues/test-fs-cp-non-utf8.js +++ b/test/known_issues/test-fs-cp-non-utf8.js @@ -10,8 +10,7 @@ if (!common.isLinux) { } const assert = require('assert'); -const { join } = require('path'); -const path = require('path'); +const { sep } = require('path'); const tmpdir = require('../common/tmpdir'); const { cpSync, @@ -22,8 +21,8 @@ const { } = require('fs'); tmpdir.refresh(); -const tmpdirPath = Buffer.from(join(tmpdir.path, 'a', 'c')); -const sepBuf = Buffer.from(path.sep); +const tmpdirPath = Buffer.from(tmpdir.resolve('a', 'c')); +const sepBuf = Buffer.from(sep); mkdirSync(tmpdirPath, { recursive: true }); @@ -48,7 +47,7 @@ assert.strictEqual(readFileSync(testPath, 'utf8'), 'test content'); // The cpSync is expected to fail because the implementation does not // properly handle non-UTF8 names in the path. -cpSync(join(tmpdir.path, 'a'), join(tmpdir.path, 'b'), { +cpSync(tmpdir.resolve('a'), tmpdir.resolve('b'), { recursive: true, filter: common.mustCall(() => true, 1), }); diff --git a/test/parallel/test-common-wpt-runner.js b/test/parallel/test-common-wpt-runner.js index ea41caa6cefc..446757f50d20 100644 --- a/test/parallel/test-common-wpt-runner.js +++ b/test/parallel/test-common-wpt-runner.js @@ -65,7 +65,7 @@ function main() { const atob = discover('atob'); assert.strictEqual(atob.serial, false); assert.deepStrictEqual(atob.tests.map((test) => test.id), ['base64.any.html', 'base64.any.worker.html']); - const reportRoot = path.join(tmpdir.path, 'reports'); + const reportRoot = tmpdir.resolve('reports'); const canReport = ['darwin', 'linux', 'win32'].includes(process.platform); if (canReport) fs.mkdirSync(reportRoot, { recursive: true }); for (const [index, group] of atob.tests.entries()) { @@ -104,7 +104,7 @@ function main() { assert.doesNotMatch(skippedOutput, /\[PASS\]/); if (common.hasSQLite) { - const root = path.join(tmpdir.path, 'discovery'); + const root = tmpdir.resolve('discovery'); const directory = path.join(root, '.tmp.probe'); fs.mkdirSync(directory, { recursive: true }); const sentinel = path.join(directory, 'sentinel'); diff --git a/test/parallel/test-config-file.js b/test/parallel/test-config-file.js index 127e862eecc8..32c81f562dbe 100644 --- a/test/parallel/test-config-file.js +++ b/test/parallel/test-config-file.js @@ -11,7 +11,6 @@ const tmpdir = require('../common/tmpdir'); const assert = require('node:assert'); const { test, it, describe } = require('node:test'); const { chmodSync, writeFileSync, constants } = require('node:fs'); -const { join } = require('node:path'); const onlyIfNodeOptionsSupport = { skip: process.config.variables.node_without_node_options }; const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; @@ -60,7 +59,7 @@ describe('runtime version checks', () => { async function runConfig(config, filename = 'version-config.json') { tmpdir.refresh(); - const configPath = join(tmpdir.path, filename); + const configPath = tmpdir.resolve(filename); writeFileSync(configPath, JSON.stringify(config)); return spawnPromisified(process.execPath, [ @@ -775,7 +774,7 @@ test('should throw an error when the file is non readable', { skip: isWindows || process.getuid() === 0, }, async () => { tmpdir.refresh(); - const dest = join(tmpdir.path, 'node.config.json'); + const dest = tmpdir.resolve('node.config.json'); writeFileSync(dest, JSON.stringify({ nodeOptions: { 'max-http-header-size': 10 } })); diff --git a/test/parallel/test-crypto-key-store.js b/test/parallel/test-crypto-key-store.js index 8c8032cb5fbc..424c6d4e2ab4 100644 --- a/test/parallel/test-crypto-key-store.js +++ b/test/parallel/test-crypto-key-store.js @@ -12,7 +12,6 @@ if (isBoringSSL) const assert = require('assert'); const fs = require('fs'); -const path = require('path'); const { pathToFileURL } = require('url'); const { createPublicKey, @@ -36,7 +35,7 @@ const data = Buffer.from('hello store'); { const { privateKey, publicKey } = generateKeyPairSync('ed25519'); - const file = path.join(tmpdir.path, 'priv.pem'); + const file = tmpdir.resolve('priv.pem'); fs.writeFileSync(file, privateKey.export({ format: 'pem', type: 'pkcs8' })); const url = pathToFileURL(file); @@ -66,7 +65,7 @@ const data = Buffer.from('hello store'); const { privateKey, publicKey } = generateKeyPairSync('rsa', { modulusLength: 2048, }); - const file = path.join(tmpdir.path, 'rsa.pem'); + const file = tmpdir.resolve('rsa.pem'); fs.writeFileSync(file, privateKey.export({ format: 'pem', type: 'pkcs8' })); const url = pathToFileURL(file); const plaintext = Buffer.from('hello rsa store'); @@ -91,7 +90,7 @@ const data = Buffer.from('hello store'); } else { const alice = generateKeyPairSync('x25519'); const bob = generateKeyPairSync('x25519'); - const file = path.join(tmpdir.path, 'x25519.pem'); + const file = tmpdir.resolve('x25519.pem'); fs.writeFileSync(file, alice.privateKey.export({ format: 'pem', type: 'pkcs8', @@ -117,7 +116,7 @@ const data = Buffer.from('hello store'); // Encrypted PKCS#8 with passphrase via { key: url, passphrase }. const passphrase = 'correct-passphrase'; const { privateKey, publicKey } = generateKeyPairSync('ed25519'); - const file = path.join(tmpdir.path, 'enc.pem'); + const file = tmpdir.resolve('enc.pem'); fs.writeFileSync(file, privateKey.export({ format: 'pem', type: 'pkcs8', cipher: 'aes-256-cbc', passphrase, })); @@ -139,7 +138,7 @@ const data = Buffer.from('hello store'); { // A URL is only accepted in private-key contexts. - const url = pathToFileURL(path.join(tmpdir.path, 'priv.pem')); + const url = pathToFileURL(tmpdir.resolve('priv.pem')); assert.throws(() => createPublicKey(url), { code: 'ERR_INVALID_ARG_TYPE', }); @@ -188,7 +187,7 @@ const data = Buffer.from('hello store'); { // A readable URI that holds no private key is distinguishable from a URI // that could not be opened at all. - const file = path.join(tmpdir.path, 'nope.pem'); + const file = tmpdir.resolve('nope.pem'); fs.writeFileSync(file, 'not a key'); assert.throws(() => createPrivateKey(pathToFileURL(file)), { code: 'ERR_CRYPTO_OPERATION_FAILED', @@ -199,7 +198,7 @@ const data = Buffer.from('hello store'); // portable either: some builds leave a generic STORE `unsupported` on top of // the error the loader itself raised. The reason is reported either way. assert.throws( - () => createPrivateKey(pathToFileURL(path.join(tmpdir.path, 'missing.pem'))), + () => createPrivateKey(pathToFileURL(tmpdir.resolve('missing.pem'))), (err) => { assert.match([err.message, ...err.opensslErrorStack ?? []].join('\n'), /No such file or directory/); @@ -219,7 +218,7 @@ const data = Buffer.from('hello store'); // Only a genuine URL selects the STORE loader. A plain object that merely // exposes `href` and `protocol` must not be treated as one, otherwise an // attacker-supplied JWK could redirect the load to a URI of their choosing. - const file = path.join(tmpdir.path, 'priv.pem'); + const file = tmpdir.resolve('priv.pem'); const spoofed = { kty: 'EC', crv: 'P-256', @@ -244,9 +243,9 @@ const data = Buffer.from('hello store'); // Read the URI from the URL's private state. Public accessors on a branded // subclass must not redirect a previously created URL to a different key. const trustedHref = pathToFileURL( - path.join(tmpdir.path, 'priv.pem')).href; + tmpdir.resolve('priv.pem')).href; const redirectHref = pathToFileURL( - path.join(tmpdir.path, 'rsa.pem')).href; + tmpdir.resolve('rsa.pem')).href; class RedirectingURL extends URL { get href() { return redirectHref; } } @@ -274,7 +273,7 @@ const data = Buffer.from('hello store'); // Replacing `protocol` must not turn an opaque STORE URI into a file path. const filePathname = pathToFileURL( - path.join(tmpdir.path, 'priv.pem')).pathname; + tmpdir.resolve('priv.pem')).pathname; const opaqueURL = new URL(`pkcs11:${filePathname}`); const protocolDescriptor = Object.getOwnPropertyDescriptor( URL.prototype, 'protocol'); @@ -294,7 +293,7 @@ const data = Buffer.from('hello store'); { // The URI is handed to OpenSSL as a NUL-terminated C string, so an embedded // NUL must be rejected rather than silently truncating the path. - const file = path.join(tmpdir.path, 'priv.pem'); + const file = tmpdir.resolve('priv.pem'); assert.throws( () => createPrivateKey(new URL(`${pathToFileURL(file).href}%00.txt`)), { code: 'ERR_INVALID_ARG_VALUE', diff --git a/test/parallel/test-diagnostics-channel-child-process.js b/test/parallel/test-diagnostics-channel-child-process.js index 1d16fd429877..56ebfb239569 100644 --- a/test/parallel/test-diagnostics-channel-child-process.js +++ b/test/parallel/test-diagnostics-channel-child-process.js @@ -3,7 +3,6 @@ const common = require('../common'); const assert = require('assert'); const { spawn, ChildProcess } = require('child_process'); const dc = require('diagnostics_channel'); -const path = require('path'); const fs = require('fs'); const tmpdir = require('../common/tmpdir'); @@ -67,7 +66,7 @@ const testFailingSpawnENOENT = common.mustCall(() => { const testFailingSpawnEACCES = !common.isWindows ? common.mustCall(() => { tmpdir.refresh(); - const noExecFile = path.join(tmpdir.path, 'no-exec'); + const noExecFile = tmpdir.resolve('no-exec'); fs.writeFileSync(noExecFile, ''); fs.chmodSync(noExecFile, 0o644); diff --git a/test/parallel/test-fs-chown-negative-one.js b/test/parallel/test-fs-chown-negative-one.js index 092d4782d115..4dec42371f44 100644 --- a/test/parallel/test-fs-chown-negative-one.js +++ b/test/parallel/test-fs-chown-negative-one.js @@ -3,12 +3,11 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -const testFile = path.join(tmpdir.path, 'chown-test-file.txt'); +const testFile = tmpdir.resolve('chown-test-file.txt'); fs.writeFileSync(testFile, 'test content for chown'); diff --git a/test/parallel/test-fs-cp-async-symlink-targets.mjs b/test/parallel/test-fs-cp-async-symlink-targets.mjs index 81e861c90859..970ebb7145a1 100644 --- a/test/parallel/test-fs-cp-async-symlink-targets.mjs +++ b/test/parallel/test-fs-cp-async-symlink-targets.mjs @@ -17,7 +17,7 @@ mkdirSync(join(src, 'real'), { recursive: true }); writeFileSync(join(src, 'real', 'file'), 'data'); symlinkSync('real', join(src, 'alias')); symlinkSync('alias/file', join(src, 'link')); -const absoluteTarget = join(tmpdir.path, 'x', '..', 'elsewhere'); +const absoluteTarget = tmpdir.resolve('x', '..', 'elsewhere'); symlinkSync(absoluteTarget, join(src, 'abs')); for (const filter of [undefined, () => true]) { diff --git a/test/parallel/test-fs-cp-sync-dereference.js b/test/parallel/test-fs-cp-sync-dereference.js index dffb5b171c4d..8267b898f15d 100644 --- a/test/parallel/test-fs-cp-sync-dereference.js +++ b/test/parallel/test-fs-cp-sync-dereference.js @@ -17,19 +17,15 @@ const { statSync } = require('fs'); -const { - join, -} = require('path'); - const assert = require('assert'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -const pathA = join(tmpdir.path, 'a'); // file -const pathB = join(tmpdir.path, 'b'); // directory -const pathC = join(tmpdir.path, 'c'); // c -> b -const pathD = join(tmpdir.path, 'd'); // d -> b +const pathA = tmpdir.resolve('a'); // file +const pathB = tmpdir.resolve('b'); // directory +const pathC = tmpdir.resolve('c'); // c -> b +const pathD = tmpdir.resolve('d'); // d -> b writeFileSync(pathA, 'file a'); mkdirSync(pathB); diff --git a/test/parallel/test-fs-cp-sync-unicode-dest.mjs b/test/parallel/test-fs-cp-sync-unicode-dest.mjs index 0638b98180c5..af1da77a78ca 100644 --- a/test/parallel/test-fs-cp-sync-unicode-dest.mjs +++ b/test/parallel/test-fs-cp-sync-unicode-dest.mjs @@ -8,12 +8,12 @@ import tmpdir from '../common/tmpdir.js'; tmpdir.refresh(); -const src = join(tmpdir.path, 'src'); +const src = tmpdir.resolve('src'); mkdirSync(join(src, 'subdir'), { recursive: true }); writeFileSync(join(src, 'file1.txt'), 'Hello World'); writeFileSync(join(src, 'subdir', 'nested.txt'), 'Nested File'); -const dest = join(tmpdir.path, 'Eyjafjallajökull-Pranckevičius'); +const dest = tmpdir.resolve('Eyjafjallajökull-Pranckevičius'); cpSync(src, dest, { recursive: true, force: true }); const destFiles = readdirSync(dest); diff --git a/test/parallel/test-fs-fchown-negative-one.js b/test/parallel/test-fs-fchown-negative-one.js index e88b3a2428fd..2f57bc5902f3 100644 --- a/test/parallel/test-fs-fchown-negative-one.js +++ b/test/parallel/test-fs-fchown-negative-one.js @@ -3,12 +3,11 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -const testFilePath = path.join(tmpdir.path, 'fchown-test-file.txt'); +const testFilePath = tmpdir.resolve('fchown-test-file.txt'); fs.writeFileSync(testFilePath, 'test content for fchown'); diff --git a/test/parallel/test-fs-lchown-negative-one.js b/test/parallel/test-fs-lchown-negative-one.js index d681f3e429b3..d047a30a6d12 100644 --- a/test/parallel/test-fs-lchown-negative-one.js +++ b/test/parallel/test-fs-lchown-negative-one.js @@ -3,13 +3,12 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -const testFile = path.join(tmpdir.path, 'lchown-test-file.txt'); -const testLink = path.join(tmpdir.path, 'lchown-test-link'); +const testFile = tmpdir.resolve('lchown-test-file.txt'); +const testLink = tmpdir.resolve('lchown-test-link'); fs.writeFileSync(testFile, 'test content for lchown'); fs.symlinkSync(testFile, testLink); diff --git a/test/parallel/test-fs-mkdtemp-buffer.js b/test/parallel/test-fs-mkdtemp-buffer.js index c9c04d57eaca..e8be532fed4e 100644 --- a/test/parallel/test-fs-mkdtemp-buffer.js +++ b/test/parallel/test-fs-mkdtemp-buffer.js @@ -2,12 +2,11 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -const prefixString = path.join(tmpdir.path, 'buffer-'); +const prefixString = tmpdir.resolve('buffer-'); const prefixBuffer = Buffer.from(prefixString); // 1. Test Sync API diff --git a/test/parallel/test-fs-mkdtempDisposableSync.js b/test/parallel/test-fs-mkdtempDisposableSync.js index 15d4ff415da1..4748650c0510 100644 --- a/test/parallel/test-fs-mkdtempDisposableSync.js +++ b/test/parallel/test-fs-mkdtempDisposableSync.js @@ -48,8 +48,8 @@ if (isMainThread) { const first = fs.mkdtempDisposableSync('first.'); const second = fs.mkdtempDisposableSync('second.'); - const fullFirstPath = path.join(tmpdir.path, first.path); - const fullSecondPath = path.join(tmpdir.path, second.path); + const fullFirstPath = tmpdir.resolve(first.path); + const fullSecondPath = tmpdir.resolve(second.path); assert(fs.existsSync(fullFirstPath)); assert(fs.existsSync(fullSecondPath)); diff --git a/test/parallel/test-fs-promises-mkdtempDisposable.js b/test/parallel/test-fs-promises-mkdtempDisposable.js index 8f51a50f7899..5fd5ff5b2432 100644 --- a/test/parallel/test-fs-promises-mkdtempDisposable.js +++ b/test/parallel/test-fs-promises-mkdtempDisposable.js @@ -48,8 +48,8 @@ async function chdirDoesNotAffectRemoval() { const first = await fsPromises.mkdtempDisposable('first.'); const second = await fsPromises.mkdtempDisposable('second.'); - const fullFirstPath = path.join(tmpdir.path, first.path); - const fullSecondPath = path.join(tmpdir.path, second.path); + const fullFirstPath = tmpdir.resolve(first.path); + const fullSecondPath = tmpdir.resolve(second.path); assert(fs.existsSync(fullFirstPath)); assert(fs.existsSync(fullSecondPath)); diff --git a/test/parallel/test-fs-readfile-utf8-fast-path.js b/test/parallel/test-fs-readfile-utf8-fast-path.js index 18d0d884dfa4..019a709438d4 100644 --- a/test/parallel/test-fs-readfile-utf8-fast-path.js +++ b/test/parallel/test-fs-readfile-utf8-fast-path.js @@ -2,7 +2,6 @@ require('../common'); const fs = require('node:fs'); -const path = require('node:path'); const assert = require('node:assert'); const { describe, it } = require('node:test'); const tmpdir = require('../common/tmpdir'); @@ -10,7 +9,7 @@ const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); function writeFile(name, buf) { - const p = path.join(tmpdir.path, name); + const p = tmpdir.resolve(name); fs.writeFileSync(p, buf); return p; } diff --git a/test/parallel/test-fs-rmSync-special-char-additional-error.js b/test/parallel/test-fs-rmSync-special-char-additional-error.js index 51e925cdc9b4..4ac93ea7dc10 100644 --- a/test/parallel/test-fs-rmSync-special-char-additional-error.js +++ b/test/parallel/test-fs-rmSync-special-char-additional-error.js @@ -23,7 +23,7 @@ function countOccurrences(haystack, needle) { return count; } -const dirPath = path.join(tmpdir.path, '速_dir'); +const dirPath = tmpdir.resolve('速_dir'); const filePath = path.join(dirPath, 'test_file.txt'); // Create a directory and a file within it diff --git a/test/parallel/test-fs-rmSync-special-char.js b/test/parallel/test-fs-rmSync-special-char.js index 00d7062d8b10..9c8a48265b1b 100755 --- a/test/parallel/test-fs-rmSync-special-char.js +++ b/test/parallel/test-fs-rmSync-special-char.js @@ -3,7 +3,6 @@ require('../common'); const tmpdir = require('../common/tmpdir'); const assert = require('node:assert'); const fs = require('node:fs'); -const path = require('node:path'); // This test ensures that fs.rmSync handles non-ASCII characters in file paths, // and that errors contain correctly encoded paths and err.path values. @@ -11,8 +10,8 @@ const path = require('node:path'); tmpdir.refresh(); // Prepare a clean temporary directory // Define paths with non-ASCII characters -const dirPath = path.join(tmpdir.path, '速_dir'); -const filePath = path.join(tmpdir.path, '速.txt'); +const dirPath = tmpdir.resolve('速_dir'); +const filePath = tmpdir.resolve('速.txt'); // Create a directory and a file with non-ASCII characters fs.mkdirSync(dirPath); diff --git a/test/parallel/test-fs-write-invalid-encoding.js b/test/parallel/test-fs-write-invalid-encoding.js index 64142a57cc27..2051b84e94ab 100644 --- a/test/parallel/test-fs-write-invalid-encoding.js +++ b/test/parallel/test-fs-write-invalid-encoding.js @@ -3,13 +3,12 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); async function main() { - const file = path.join(tmpdir.path, 'write-invalid-encoding'); + const file = tmpdir.resolve('write-invalid-encoding'); const handle = await fs.promises.open(file, 'w+'); try { for (const encoding of ['bad', 16]) { diff --git a/test/parallel/test-http-client-request-options-injection.js b/test/parallel/test-http-client-request-options-injection.js index 47067f1895bd..e19d37d6f890 100644 --- a/test/parallel/test-http-client-request-options-injection.js +++ b/test/parallel/test-http-client-request-options-injection.js @@ -3,7 +3,6 @@ const common = require('../common'); const assert = require('node:assert'); const http = require('node:http'); -const path = require('node:path'); const tmpdir = require('../common/tmpdir'); // Regression test: an ordinary object that happens to satisfy `isURL()` (truthy @@ -35,7 +34,7 @@ server.listen(0, common.localhostIPv4, common.mustCall(() => { password: '', search: '', hash: '', - socketPath: path.join(tmpdir.path, 'should-not-be-used.sock'), + socketPath: tmpdir.resolve('should-not-be-used.sock'), method: 'POST', headers: { 'x-injected': 'yes' }, agent: false, diff --git a/test/parallel/test-http2-respond-with-fd-finish.js b/test/parallel/test-http2-respond-with-fd-finish.js index c93858b9aac0..2572385051a0 100644 --- a/test/parallel/test-http2-respond-with-fd-finish.js +++ b/test/parallel/test-http2-respond-with-fd-finish.js @@ -14,14 +14,13 @@ if (!common.hasCrypto) common.skip('missing crypto'); const assert = require('assert'); const fs = require('fs'); -const path = require('path'); const http2 = require('http2'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); function testCleanCompletion(next) { - const smallPath = path.join(tmpdir.path, 'small.bin'); + const smallPath = tmpdir.resolve('small.bin'); const smallSize = 64; fs.writeFileSync(smallPath, Buffer.alloc(smallSize)); @@ -57,7 +56,7 @@ function testCleanCompletion(next) { } function testAbortBeforeCompletion() { - const smallPath = path.join(tmpdir.path, 'small-abort.bin'); + const smallPath = tmpdir.resolve('small-abort.bin'); const smallSize = 64; fs.writeFileSync(smallPath, Buffer.alloc(smallSize)); diff --git a/test/parallel/test-inspector-dom-storage-malformed.js b/test/parallel/test-inspector-dom-storage-malformed.js index d9ac2bbfd0be..533f2225252b 100644 --- a/test/parallel/test-inspector-dom-storage-malformed.js +++ b/test/parallel/test-inspector-dom-storage-malformed.js @@ -12,7 +12,6 @@ const { NodeInstance } = require('../common/inspector-helper.js'); const tmpdir = require('../common/tmpdir'); const assert = require('node:assert'); const { once } = require('node:events'); -const { join } = require('node:path'); const { DatabaseSync } = require('node:sqlite'); tmpdir.refresh(); @@ -21,7 +20,7 @@ tmpdir.refresh(); // the same schema without STRICT: BLOB columns have no affinity, so a TEXT // value stays TEXT. function malformedLocalStorage(name, schemaVersion, value) { - const file = join(tmpdir.path, name); + const file = tmpdir.resolve(name); const db = new DatabaseSync(file); db.exec(` CREATE TABLE nodejs_webstorage( diff --git a/test/parallel/test-module-subpath-import-long-path.js b/test/parallel/test-module-subpath-import-long-path.js index 69207746f770..b2675229c6a7 100644 --- a/test/parallel/test-module-subpath-import-long-path.js +++ b/test/parallel/test-module-subpath-import-long-path.js @@ -17,7 +17,7 @@ const TARGET = 260; // Shortest length that used to trigger the bug const fixedLen = tmpdir.path.length + 2 + 'package.json'.length; const dirNameLen = Math.max(TARGET - fixedLen, 1); -const dir = path.join(tmpdir.path, 'a'.repeat(dirNameLen)); +const dir = tmpdir.resolve('a'.repeat(dirNameLen)); const depDir = path.join(dir, 'node_modules', 'dep'); const packageJsonPath = path.join(dir, 'package.json'); diff --git a/test/parallel/test-node-run.js b/test/parallel/test-node-run.js index b276c54ca23e..88e5d61f18b4 100644 --- a/test/parallel/test-node-run.js +++ b/test/parallel/test-node-run.js @@ -232,7 +232,7 @@ describe('node --run [command]', { concurrency: !process.env.TEST_PARALLEL }, () { skip: !common.isWindows }, async () => { tmpdir.refresh(); - const projectDir = path.join(tmpdir.path, 'node-run-\u{20BB7}'); + const projectDir = tmpdir.resolve('node-run-\u{20BB7}'); const packageJsonPath = path.join(projectDir, 'package.json'); const nodeModulesBin = path.join(projectDir, 'node_modules', '.bin'); const checkScript = path.join(projectDir, 'check.js'); diff --git a/test/parallel/test-permission-drop-fs-granted-path.js b/test/parallel/test-permission-drop-fs-granted-path.js index 82d04b49040f..1c0865f32606 100644 --- a/test/parallel/test-permission-drop-fs-granted-path.js +++ b/test/parallel/test-permission-drop-fs-granted-path.js @@ -15,7 +15,7 @@ const path = require('path'); tmpdir.refresh(); -const dir = path.join(tmpdir.path, 'granted-dir'); +const dir = tmpdir.resolve('granted-dir'); fs.mkdirSync(dir); fs.writeFileSync(path.join(dir, 'item1.txt'), 'aaa'); fs.writeFileSync(path.join(dir, 'item2.txt'), 'bbb'); @@ -72,7 +72,7 @@ fs.writeFileSync(path.join(dir, 'item2.txt'), 'bbb'); // Grant two directories, drop one - the other remains accessible { - const dir2 = path.join(tmpdir.path, 'other-dir'); + const dir2 = tmpdir.resolve('other-dir'); fs.mkdirSync(dir2); fs.writeFileSync(path.join(dir2, 'other.txt'), 'ccc'); @@ -170,7 +170,7 @@ for (const files of [ // Grant a path that does not exist yet, then create it as a directory // dropping it still revokes the grant { - const later = path.join(tmpdir.path, 'later-dir'); + const later = tmpdir.resolve('later-dir'); const child = spawnSync(process.execPath, [ '--permission', `--allow-fs-read=${later}`, @@ -200,7 +200,7 @@ for (const files of [ // Grant a directory, then remove it - dropping it still revokes the grant { - const gone = path.join(tmpdir.path, 'gone-dir'); + const gone = tmpdir.resolve('gone-dir'); fs.mkdirSync(gone); const child = spawnSync(process.execPath, [ '--permission', diff --git a/test/parallel/test-permission-drop-fs-specific-path.js b/test/parallel/test-permission-drop-fs-specific-path.js index 0c46ee505ff3..7495b252d5ec 100644 --- a/test/parallel/test-permission-drop-fs-specific-path.js +++ b/test/parallel/test-permission-drop-fs-specific-path.js @@ -15,8 +15,8 @@ const path = require('path'); tmpdir.refresh(); -const dirA = path.join(tmpdir.path, 'dir-a'); -const dirB = path.join(tmpdir.path, 'dir-b'); +const dirA = tmpdir.resolve('dir-a'); +const dirB = tmpdir.resolve('dir-b'); fs.mkdirSync(dirA); fs.mkdirSync(dirB); fs.writeFileSync(path.join(dirA, 'a.txt'), 'aaa'); diff --git a/test/parallel/test-permission-fs-read.js b/test/parallel/test-permission-fs-read.js index 6261fe24020d..733a7952fa6c 100644 --- a/test/parallel/test-permission-fs-read.js +++ b/test/parallel/test-permission-fs-read.js @@ -30,9 +30,9 @@ const commonPath = path.join(__filename, '../../common'); } { - const boundaryFile = path.join(tmpdir.path, 'secret'); + const boundaryFile = tmpdir.resolve('secret'); const grantedFiles = ['secret1', 'secret2', 'secret3'] - .map((file) => path.join(tmpdir.path, file)); + .map((file) => tmpdir.resolve(file)); fs.writeFileSync(boundaryFile, 'protected'); for (const file of grantedFiles) { diff --git a/test/parallel/test-permission-fs-write-report.js b/test/parallel/test-permission-fs-write-report.js index 7a726ce8e50a..384ddf38a9c7 100644 --- a/test/parallel/test-permission-fs-write-report.js +++ b/test/parallel/test-permission-fs-write-report.js @@ -50,7 +50,7 @@ tmpdir.refresh(); } { - const reportPath = path.join(tmpdir.path, 'report.json'); + const reportPath = tmpdir.resolve('report.json'); spawnSyncAndExitWithoutError( process.execPath, [ @@ -76,8 +76,8 @@ spawnSyncAndExitWithoutError( ); { - const allowedDir = path.join(tmpdir.path, 'report-allowed'); - const deniedDir = path.join(tmpdir.path, 'report-denied'); + const allowedDir = tmpdir.resolve('report-allowed'); + const deniedDir = tmpdir.resolve('report-denied'); fs.mkdirSync(allowedDir); fs.mkdirSync(deniedDir); @@ -108,8 +108,8 @@ spawnSyncAndExitWithoutError( } { - const allowedDir = path.join(tmpdir.path, 'report-filename-allowed'); - const deniedDir = path.join(tmpdir.path, 'report-filename-denied'); + const allowedDir = tmpdir.resolve('report-filename-allowed'); + const deniedDir = tmpdir.resolve('report-filename-denied'); fs.mkdirSync(allowedDir); fs.mkdirSync(deniedDir); diff --git a/test/parallel/test-permission-has-reference-types.js b/test/parallel/test-permission-has-reference-types.js index 0f92aa2e579b..7a60c3f5103a 100644 --- a/test/parallel/test-permission-has-reference-types.js +++ b/test/parallel/test-permission-has-reference-types.js @@ -18,8 +18,8 @@ const path = require('path'); tmpdir.refresh(); -const allowedDir = path.join(tmpdir.path, 'allowed'); -const deniedDir = path.join(tmpdir.path, 'denied'); +const allowedDir = tmpdir.resolve('allowed'); +const deniedDir = tmpdir.resolve('denied'); fs.mkdirSync(allowedDir); fs.mkdirSync(deniedDir); diff --git a/test/parallel/test-permission-openssl-store.js b/test/parallel/test-permission-openssl-store.js index b47553a9e88a..5ac89742266d 100644 --- a/test/parallel/test-permission-openssl-store.js +++ b/test/parallel/test-permission-openssl-store.js @@ -14,14 +14,13 @@ if (isBoringSSL) const assert = require('assert'); const dc = require('diagnostics_channel'); const fs = require('fs'); -const path = require('path'); const { pathToFileURL } = require('url'); const { createPrivateKey, generateKeyPairSync } = require('crypto'); const { spawnSync } = require('child_process'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -const file = path.join(tmpdir.path, 'priv.pem'); +const file = tmpdir.resolve('priv.pem'); fs.writeFileSync( file, generateKeyPairSync('ed25519').privateKey.export({ format: 'pem', type: 'pkcs8', @@ -83,7 +82,7 @@ assert.doesNotMatch(JSON.stringify(messages[0]), new RegExp(secret)); // OpenSSL tries the file loader before the loader identified by an opaque URI. { const opaqueFile = 'pkcs11:priv.pem'; - fs.copyFileSync(file, path.join(tmpdir.path, opaqueFile)); + fs.copyFileSync(file, tmpdir.resolve(opaqueFile)); const { status, stdout } = spawnSync(process.execPath, [ '--permission', '--allow-openssl-store', '-e', `try { require('crypto').createPrivateKey(new URL(${JSON.stringify(opaqueFile)})); console.log('LOADED'); } catch (e) { console.log(e.code, e.permission); }`, diff --git a/test/parallel/test-repl-history-init-fail-leak.js b/test/parallel/test-repl-history-init-fail-leak.js index 9992560bcc28..5653d36614cc 100644 --- a/test/parallel/test-repl-history-init-fail-leak.js +++ b/test/parallel/test-repl-history-init-fail-leak.js @@ -3,7 +3,6 @@ const common = require('../common'); const fs = require('fs'); -const path = require('path'); const { ReplHistory } = require('internal/repl/history'); const assert = require('assert'); @@ -12,7 +11,7 @@ common.skipIfInspectorDisabled(); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); -const historyPath = path.join(tmpdir.path, '.node_repl_history'); +const historyPath = tmpdir.resolve('.node_repl_history'); fs.writeFileSync(historyPath, 'dummy\n'); diff --git a/test/parallel/test-sqlite-backup.mjs b/test/parallel/test-sqlite-backup.mjs index 212bf54e98ca..d65a72f31bee 100644 --- a/test/parallel/test-sqlite-backup.mjs +++ b/test/parallel/test-sqlite-backup.mjs @@ -7,7 +7,6 @@ import { } from '../common/index.mjs'; import fixtures from '../common/fixtures.js'; import tmpdir from '../common/tmpdir.js'; -import { join } from 'node:path'; import { describe, test } from 'node:test'; import { writeFileSync } from 'node:fs'; import { pathToFileURL } from 'node:url'; @@ -21,7 +20,7 @@ let cnt = 0; tmpdir.refresh(); function nextDb() { - return join(tmpdir.path, `database-${cnt++}.db`); + return tmpdir.resolve(`database-${cnt++}.db`); } function makeSourceDb(dbPath = ':memory:') { diff --git a/test/parallel/test-sqlite-database.js b/test/parallel/test-sqlite-database.js index 66d273b6d010..998a146ee8c1 100644 --- a/test/parallel/test-sqlite-database.js +++ b/test/parallel/test-sqlite-database.js @@ -11,7 +11,7 @@ let cnt = 0; tmpdir.refresh(); function nextDb() { - return join(tmpdir.path, `database-${cnt++}.db`); + return tmpdir.resolve(`database-${cnt++}.db`); } suite('Database() constructor', () => { @@ -335,7 +335,7 @@ suite('Database.prototype.open()', () => { test('does not leave the database open after a failed open', (t) => { // Regression test for https://github.com/nodejs/node/issues/63831 - const dbDir = join(tmpdir.path, `database-dir-${cnt++}`); + const dbDir = tmpdir.resolve(`database-dir-${cnt++}`); const dbPath = join(dbDir, 'failed-open.db'); using db = new Database(dbPath, { open: false }); diff --git a/test/parallel/test-sqlite-options-getter-reentry.js b/test/parallel/test-sqlite-options-getter-reentry.js index abb845358257..956385ac3b40 100644 --- a/test/parallel/test-sqlite-options-getter-reentry.js +++ b/test/parallel/test-sqlite-options-getter-reentry.js @@ -2,7 +2,6 @@ const { skipIfSQLiteMissing } = require('../common'); skipIfSQLiteMissing(); const tmpdir = require('../common/tmpdir'); -const { join } = require('node:path'); const { backup, Database } = require('node:sqlite'); const { suite, test } = require('node:test'); @@ -166,7 +165,7 @@ suite('closing the database from an options getter', () => { test('backup() throws instead of using a closed connection', (t) => { const db = new Database(':memory:'); t.assert.throws(() => { - backup(db, join(tmpdir.path, 'getter-backup.db'), { + backup(db, tmpdir.resolve('getter-backup.db'), { get rate() { db.close(); return 1; @@ -194,7 +193,7 @@ test('options getters do not run on an already-closed database', (t) => { createSession: (db, options) => db.createSession(options), applyChangeset: (db, options) => db.applyChangeset(changeset, options), backup: (db, options) => - backup(db, join(tmpdir.path, 'closed-backup.db'), options), + backup(db, tmpdir.resolve('closed-backup.db'), options), }; // The property each method reads first, and a valid value for it, so that a diff --git a/test/parallel/test-sqlite-timeout.js b/test/parallel/test-sqlite-timeout.js index 97d40bffc736..316da34a617d 100644 --- a/test/parallel/test-sqlite-timeout.js +++ b/test/parallel/test-sqlite-timeout.js @@ -2,7 +2,6 @@ const { skipIfSQLiteMissing } = require('../common'); skipIfSQLiteMissing(); const tmpdir = require('../common/tmpdir'); -const { join } = require('node:path'); const { Database } = require('node:sqlite'); const { test } = require('node:test'); const { once } = require('node:events'); @@ -12,7 +11,7 @@ let cnt = 0; tmpdir.refresh(); function nextDb() { - return join(tmpdir.path, `database-${cnt++}.db`); + return tmpdir.resolve(`database-${cnt++}.db`); } test('waits to acquire lock', async (t) => { diff --git a/test/parallel/test-sqlite-virtual-table.js b/test/parallel/test-sqlite-virtual-table.js index 5f8c9057a795..a82e37644901 100644 --- a/test/parallel/test-sqlite-virtual-table.js +++ b/test/parallel/test-sqlite-virtual-table.js @@ -3,7 +3,6 @@ const { skipIfSQLiteMissing, mustCallAtLeast } = require('../common'); skipIfSQLiteMissing(); const assert = require('node:assert'); -const { join } = require('node:path'); const { Database } = require('node:sqlite'); const { suite, test } = require('node:test'); const tmpdir = require('../common/tmpdir'); @@ -992,7 +991,7 @@ suite('Database.prototype.createModule()', () => { suite('statements prepared while a cursor is closing', () => { test('finalizes statements prepared from a generator finally', () => { tmpdir.refresh(); - const filename = join(tmpdir.path, 'vtab-close.db'); + const filename = tmpdir.resolve('vtab-close.db'); const db = new Database(filename); db.exec('CREATE TABLE log (m TEXT)'); let late; diff --git a/test/parallel/test-webstorage.js b/test/parallel/test-webstorage.js index d8ef0819b5e1..c54d9deaa17c 100644 --- a/test/parallel/test-webstorage.js +++ b/test/parallel/test-webstorage.js @@ -6,7 +6,6 @@ const { skipIfSQLiteMissing(); const tmpdir = require('../common/tmpdir'); const assert = require('node:assert'); -const { join } = require('node:path'); const { readdir } = require('node:fs/promises'); const { endianness } = require('node:os'); const { DatabaseSync } = require('node:sqlite'); @@ -16,13 +15,13 @@ let cnt = 0; tmpdir.refresh(); function nextLocalStorage() { - return join(tmpdir.path, `${++cnt}.localstorage`); + return tmpdir.resolve(`${++cnt}.localstorage`); } // The tests below assert on which .localstorage files exist, so malformed // fixtures are named so as not to be counted among them. function nextMalformedLocalStorage() { - return join(tmpdir.path, `malformed-${++cnt}.db`); + return tmpdir.resolve(`malformed-${++cnt}.db`); } async function localStorageFiles() { diff --git a/test/parallel/test-webworker-typescript.js b/test/parallel/test-webworker-typescript.js index 08762f7fd4a5..c523f4ca92d1 100644 --- a/test/parallel/test-webworker-typescript.js +++ b/test/parallel/test-webworker-typescript.js @@ -8,7 +8,6 @@ if (!process.config.variables.node_use_amaro) { // Strip file entry types without changing the worker's module semantics. const assert = require('node:assert'); const { mkdirSync, writeFileSync } = require('node:fs'); -const { join } = require('node:path'); const { pathToFileURL } = require('node:url'); const fixtures = require('../common/fixtures'); const tmpdir = require('../common/tmpdir'); @@ -16,7 +15,7 @@ const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); function createEntry(name, source) { - const path = join(tmpdir.path, name); + const path = tmpdir.resolve(name); writeFileSync(path, source); return pathToFileURL(path); } @@ -39,7 +38,7 @@ function expectError(url, code, type = 'module') { } // Worker type takes precedence over both the extension and package type. -writeFileSync(join(tmpdir.path, 'package.json'), '{ "type": "commonjs" }'); +writeFileSync(tmpdir.resolve('package.json'), '{ "type": "commonjs" }'); for (const extension of ['ts', 'mts', 'cts']) { const url = createEntry(`entry.${extension}`, 'const type: string = typeof require; postMessage(type);'); expectMessage(url, 'undefined'); @@ -54,7 +53,7 @@ for (const extension of ['ts', 'mts', 'cts']) { } // Stripping errors reach the parent's error handler. -mkdirSync(join(tmpdir.path, 'node_modules')); +mkdirSync(tmpdir.resolve('node_modules')); expectError(createEntry('node_modules/entry.ts', 'postMessage(1);'), 'ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING'); diff --git a/test/sqlite/next-db.js b/test/sqlite/next-db.js index ae657325362b..a15c3eb097d2 100644 --- a/test/sqlite/next-db.js +++ b/test/sqlite/next-db.js @@ -1,14 +1,13 @@ 'use strict'; require('../common'); const tmpdir = require('../common/tmpdir'); -const { join } = require('node:path'); let cnt = 0; tmpdir.refresh(); function nextDb() { - return join(tmpdir.path, `database-${cnt++}.db`); + return tmpdir.resolve(`database-${cnt++}.db`); } module.exports = { nextDb }; diff --git a/test/wpt/test-webstorage.js b/test/wpt/test-webstorage.js index b0cc3d6bf13d..514658996ad5 100644 --- a/test/wpt/test-webstorage.js +++ b/test/wpt/test-webstorage.js @@ -3,13 +3,12 @@ const { skipIfSQLiteMissing } = require('../common'); skipIfSQLiteMissing(); const tmpdir = require('../common/tmpdir'); const { WPTRunner } = require('../common/wpt'); -const { join } = require('node:path'); const runner = new WPTRunner('webstorage', { concurrency: 1 }); if (!runner.isListing) tmpdir.refresh(); runner.setFlags([ - '--localstorage-file', join(tmpdir.path, 'wpt-tests.localstorage'), + '--localstorage-file', tmpdir.resolve('wpt-tests.localstorage'), ]); runner.setInitScript(` globalThis.window = globalThis;