Commit 6a91392c760 for nodejs
commit 6a91392c7603fe600846ff15741b621b9ecf830d
Author: Livia Medeiros <livia@cirno.name>
Date: Sun Nov 29 20:36:07 2026 +0800
test: prefer `tmpdir.resolve()` over `path.join(tmpdir.path, ...)`
Signed-off-by: LiviaMedeiros <livia@cirno.name>
PR-URL: https://github.com/nodejs/node/pull/67786
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
diff --git a/test/parallel/test-fastutf8stream-destroy.js b/test/parallel/test-fastutf8stream-destroy.js
index 3351842e729..34d0ff23bb7 100644
--- a/test/parallel/test-fastutf8stream-destroy.js
+++ b/test/parallel/test-fastutf8stream-destroy.js
@@ -12,7 +12,6 @@ const {
} = require('node:fs');
const { Utf8Stream } = require('node:fs');
const { isMainThread } = require('node:worker_threads');
-const { join } = require('node:path');
let fileCounter = 0;
tmpdir.refresh();
@@ -22,7 +21,7 @@ if (isMainThread) {
}
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
{
diff --git a/test/parallel/test-fastutf8stream-end.js b/test/parallel/test-fastutf8stream-end.js
index 6037cc9b878..fd6c0b9df30 100644
--- a/test/parallel/test-fastutf8stream-end.js
+++ b/test/parallel/test-fastutf8stream-end.js
@@ -5,7 +5,6 @@ const tmpdir = require('../common/tmpdir');
const assert = require('node:assert');
const fs = require('node:fs');
const { Utf8Stream } = require('node:fs');
-const { join } = require('node:path');
const { isMainThread } = require('node:worker_threads');
tmpdir.refresh();
@@ -16,7 +15,7 @@ if (isMainThread) {
}
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
runTests(false);
diff --git a/test/parallel/test-fastutf8stream-flush-mocks.js b/test/parallel/test-fastutf8stream-flush-mocks.js
index 3c6ad039cf4..6845ea5bc38 100644
--- a/test/parallel/test-fastutf8stream-flush-mocks.js
+++ b/test/parallel/test-fastutf8stream-flush-mocks.js
@@ -13,7 +13,6 @@ const {
writeSync,
write,
} = require('node:fs');
-const { join } = require('node:path');
const { Utf8Stream } = require('node:fs');
const { isMainThread } = require('node:worker_threads');
@@ -42,7 +41,7 @@ if (isMainThread) {
let fileCounter = 0;
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
runTests(false);
diff --git a/test/parallel/test-fastutf8stream-flush-sync.js b/test/parallel/test-fastutf8stream-flush-sync.js
index 6c7d728fec5..82b03362d3a 100644
--- a/test/parallel/test-fastutf8stream-flush-sync.js
+++ b/test/parallel/test-fastutf8stream-flush-sync.js
@@ -10,7 +10,6 @@ const {
writeSync,
} = require('node:fs');
const { Utf8Stream } = require('node:fs');
-const { join } = require('node:path');
const { isMainThread } = require('node:worker_threads');
@@ -22,7 +21,7 @@ if (isMainThread) {
}
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
runTests(false);
diff --git a/test/parallel/test-fastutf8stream-flush.js b/test/parallel/test-fastutf8stream-flush.js
index 14d77166c4c..e8297bdbef5 100644
--- a/test/parallel/test-fastutf8stream-flush.js
+++ b/test/parallel/test-fastutf8stream-flush.js
@@ -22,7 +22,7 @@ if (isMainThread) {
process.umask(0o000);
}
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
runTests(false);
diff --git a/test/parallel/test-fastutf8stream-fsync.js b/test/parallel/test-fastutf8stream-fsync.js
index b4b8786ce08..09c5e227327 100644
--- a/test/parallel/test-fastutf8stream-fsync.js
+++ b/test/parallel/test-fastutf8stream-fsync.js
@@ -10,7 +10,6 @@ const {
readFileSync,
} = require('node:fs');
const { Utf8Stream } = require('node:fs');
-const { join } = require('node:path');
const { isMainThread } = require('node:worker_threads');
tmpdir.refresh();
@@ -21,7 +20,7 @@ if (isMainThread) {
}
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
{
diff --git a/test/parallel/test-fastutf8stream-minlength.js b/test/parallel/test-fastutf8stream-minlength.js
index 308972c8678..dcf8ffae380 100644
--- a/test/parallel/test-fastutf8stream-minlength.js
+++ b/test/parallel/test-fastutf8stream-minlength.js
@@ -8,13 +8,12 @@ const {
openSync,
} = require('node:fs');
const { Utf8Stream } = require('node:fs');
-const { join } = require('node:path');
tmpdir.refresh();
let fileCounter = 0;
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
const MAX_WRITE = 16 * 1024;
diff --git a/test/parallel/test-fastutf8stream-mode.js b/test/parallel/test-fastutf8stream-mode.js
index 5af23a1b39b..34c264b3653 100644
--- a/test/parallel/test-fastutf8stream-mode.js
+++ b/test/parallel/test-fastutf8stream-mode.js
@@ -20,7 +20,7 @@ if (isMainThread) {
}
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
const isWindows = process.platform === 'win32';
diff --git a/test/parallel/test-fastutf8stream-partial-write-utf8.js b/test/parallel/test-fastutf8stream-partial-write-utf8.js
index 3a56fcf71a7..b637b638fb2 100644
--- a/test/parallel/test-fastutf8stream-partial-write-utf8.js
+++ b/test/parallel/test-fastutf8stream-partial-write-utf8.js
@@ -12,7 +12,6 @@ const {
writeSync,
} = require('node:fs');
const { Utf8Stream } = require('node:fs');
-const { join } = require('node:path');
const { isMainThread } = require('node:worker_threads');
tmpdir.refresh();
@@ -23,7 +22,7 @@ if (isMainThread) {
let fileCounter = 0;
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-partial-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-partial-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
runTests(false);
diff --git a/test/parallel/test-fastutf8stream-periodicflush.js b/test/parallel/test-fastutf8stream-periodicflush.js
index ed9f8aef883..ce858709666 100644
--- a/test/parallel/test-fastutf8stream-periodicflush.js
+++ b/test/parallel/test-fastutf8stream-periodicflush.js
@@ -8,7 +8,6 @@ const {
readFile,
} = require('node:fs');
const { Utf8Stream } = require('node:fs');
-const { join } = require('node:path');
const { isMainThread } = require('node:worker_threads');
tmpdir.refresh();
@@ -18,7 +17,7 @@ if (isMainThread) {
process.umask(0o000);
}
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
runTests(false);
diff --git a/test/parallel/test-fastutf8stream-reopen.js b/test/parallel/test-fastutf8stream-reopen.js
index 99c62ca267a..de99f4c2fc7 100644
--- a/test/parallel/test-fastutf8stream-reopen.js
+++ b/test/parallel/test-fastutf8stream-reopen.js
@@ -11,7 +11,6 @@ const {
write,
} = require('node:fs');
const { Utf8Stream } = require('node:fs');
-const { join } = require('node:path');
const { isMainThread } = require('node:worker_threads');
tmpdir.refresh();
@@ -22,7 +21,7 @@ if (isMainThread) {
}
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
runTests(false);
diff --git a/test/parallel/test-fastutf8stream-retry.js b/test/parallel/test-fastutf8stream-retry.js
index e1b29ed27b3..f8fb41837d6 100644
--- a/test/parallel/test-fastutf8stream-retry.js
+++ b/test/parallel/test-fastutf8stream-retry.js
@@ -10,7 +10,6 @@ const {
readFile,
} = require('node:fs');
const { Utf8Stream } = require('node:fs');
-const { join } = require('node:path');
const { isMainThread } = require('node:worker_threads');
tmpdir.refresh();
@@ -21,7 +20,7 @@ if (isMainThread) {
}
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
runTests(false);
diff --git a/test/parallel/test-fastutf8stream-sync.js b/test/parallel/test-fastutf8stream-sync.js
index 4eeaf36fe4a..1093936c039 100644
--- a/test/parallel/test-fastutf8stream-sync.js
+++ b/test/parallel/test-fastutf8stream-sync.js
@@ -13,7 +13,6 @@ const {
stat,
} = require('node:fs');
const { Utf8Stream } = require('node:fs');
-const { join } = require('node:path');
const { isMainThread } = require('node:worker_threads');
tmpdir.refresh();
@@ -23,7 +22,7 @@ if (isMainThread) {
}
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
{
diff --git a/test/parallel/test-fastutf8stream-write-arraybufferview.js b/test/parallel/test-fastutf8stream-write-arraybufferview.js
index cd65f4706f2..bb653ef3113 100644
--- a/test/parallel/test-fastutf8stream-write-arraybufferview.js
+++ b/test/parallel/test-fastutf8stream-write-arraybufferview.js
@@ -14,13 +14,12 @@ const {
readFile,
Utf8Stream,
} = require('node:fs');
-const { join } = require('node:path');
tmpdir.refresh();
let fileCounter = 0;
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-abv-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-abv-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
function writeAndVerify(sync, data, expected) {
diff --git a/test/parallel/test-fastutf8stream-write-buffer.js b/test/parallel/test-fastutf8stream-write-buffer.js
index 421d140a01e..f655db3fa8d 100644
--- a/test/parallel/test-fastutf8stream-write-buffer.js
+++ b/test/parallel/test-fastutf8stream-write-buffer.js
@@ -11,13 +11,12 @@ const {
readFile,
Utf8Stream,
} = require('node:fs');
-const { join } = require('node:path');
tmpdir.refresh();
let fileCounter = 0;
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
runTests(false);
diff --git a/test/parallel/test-fastutf8stream-write.js b/test/parallel/test-fastutf8stream-write.js
index 432b044e165..efd53da5be5 100644
--- a/test/parallel/test-fastutf8stream-write.js
+++ b/test/parallel/test-fastutf8stream-write.js
@@ -12,7 +12,6 @@ const {
stat,
} = require('node:fs');
const { Utf8Stream } = require('node:fs');
-const { join } = require('node:path');
const { isMainThread } = require('node:worker_threads');
tmpdir.refresh();
@@ -22,7 +21,7 @@ if (isMainThread) {
}
function getTempFile() {
- return join(tmpdir.path, `fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
+ return tmpdir.resolve(`fastutf8stream-${process.pid}-${Date.now()}-${fileCounter++}.log`);
}
runTests(false);
diff --git a/test/parallel/test-vfs-load.js b/test/parallel/test-vfs-load.js
index 27735d86773..e1ddc628ddc 100644
--- a/test/parallel/test-vfs-load.js
+++ b/test/parallel/test-vfs-load.js
@@ -19,7 +19,7 @@ const { spawnSync } = require('child_process');
tmpdir.refresh();
let id = 0;
-function fixture(name) { return path.join(tmpdir.path, `${id++}-${name}`); }
+function fixture(name) { return tmpdir.resolve(`${id++}-${name}`); }
function run(args) {
return spawnSync(process.execPath, args, { encoding: 'utf8' });
@@ -281,7 +281,7 @@ require('worker_threads').parentPort.postMessage('unexpected');
// there.
{
const oddName = common.isWindows ? `${id++}-od d $x` : `${id++}-od d "q" $x`;
- const dir = path.join(tmpdir.path, oddName);
+ const dir = tmpdir.resolve(oddName);
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(path.join(dir, 'index.js'), 'console.log("ran:odd");\n');
const res = run([`--vfs-load=${dir}`]);
diff --git a/test/parallel/test-vfs-real-provider-handle.js b/test/parallel/test-vfs-real-provider-handle.js
index 7910e6f7876..3ca3e7dfd26 100644
--- a/test/parallel/test-vfs-real-provider-handle.js
+++ b/test/parallel/test-vfs-real-provider-handle.js
@@ -13,7 +13,7 @@ const vfs = require('node:vfs');
const { getVirtualFd } = require('internal/vfs/fd');
tmpdir.refresh();
-const root = path.join(tmpdir.path, 'real-handle');
+const root = tmpdir.resolve('real-handle');
fs.mkdirSync(root, { recursive: true });
const myVfs = vfs.create(new vfs.RealFSProvider(root));
diff --git a/test/parallel/test-vfs-real-provider-promises.js b/test/parallel/test-vfs-real-provider-promises.js
index 3822a718db5..70ef263d613 100644
--- a/test/parallel/test-vfs-real-provider-promises.js
+++ b/test/parallel/test-vfs-real-provider-promises.js
@@ -8,11 +8,10 @@ const common = require('../common');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
const fs = require('fs');
-const path = require('path');
const vfs = require('node:vfs');
tmpdir.refresh();
-const root = path.join(tmpdir.path, 'real-provider-promises');
+const root = tmpdir.resolve('real-provider-promises');
fs.mkdirSync(root, { recursive: true });
const myVfs = vfs.create(new vfs.RealFSProvider(root));
diff --git a/test/parallel/test-vfs-real-provider-symlinks.js b/test/parallel/test-vfs-real-provider-symlinks.js
index 5c946bbfad8..7fcfa9bed5c 100644
--- a/test/parallel/test-vfs-real-provider-symlinks.js
+++ b/test/parallel/test-vfs-real-provider-symlinks.js
@@ -11,7 +11,7 @@ const path = require('path');
const vfs = require('node:vfs');
tmpdir.refresh();
-const root = path.join(tmpdir.path, 'real-symlinks');
+const root = tmpdir.resolve('real-symlinks');
fs.mkdirSync(root, { recursive: true });
const myVfs = vfs.create(new vfs.RealFSProvider(root));
@@ -79,14 +79,14 @@ const myVfs = vfs.create(new vfs.RealFSProvider(root));
// Symlink that points outside root: realpath rejects with EACCES
{
- fs.writeFileSync(path.join(tmpdir.path, 'outside.txt'), 'forbidden');
- fs.symlinkSync(path.join(tmpdir.path, 'outside.txt'),
+ fs.writeFileSync(tmpdir.resolve('outside.txt'), 'forbidden');
+ fs.symlinkSync(tmpdir.resolve('outside.txt'),
path.join(root, 'esc-link'));
// Readlink returns the absolute target as-is (no translation since it's
// outside the root)
const target = myVfs.readlinkSync('/esc-link');
- assert.strictEqual(target, path.join(tmpdir.path, 'outside.txt'));
+ assert.strictEqual(target, tmpdir.resolve('outside.txt'));
// Realpath rejects: the resolved target escapes root
assert.throws(() => myVfs.realpathSync('/esc-link'), { code: 'EACCES' });
diff --git a/test/parallel/test-vfs-real-provider-watch.js b/test/parallel/test-vfs-real-provider-watch.js
index fc1249837fa..d1729e7389c 100644
--- a/test/parallel/test-vfs-real-provider-watch.js
+++ b/test/parallel/test-vfs-real-provider-watch.js
@@ -15,7 +15,7 @@ const path = require('path');
const vfs = require('node:vfs');
tmpdir.refresh();
-const root = path.join(tmpdir.path, 'real-provider-watch');
+const root = tmpdir.resolve('real-provider-watch');
fs.mkdirSync(root, { recursive: true });
const myVfs = vfs.create(new vfs.RealFSProvider(root));
diff --git a/test/parallel/test-vfs-real-provider.js b/test/parallel/test-vfs-real-provider.js
index f8e6ae31be3..0db8599eb54 100644
--- a/test/parallel/test-vfs-real-provider.js
+++ b/test/parallel/test-vfs-real-provider.js
@@ -16,7 +16,7 @@ const vfs = require('node:vfs');
tmpdir.refresh();
-const testDir = path.join(tmpdir.path, 'vfs-real-provider');
+const testDir = tmpdir.resolve('vfs-real-provider');
fs.mkdirSync(testDir, { recursive: true });
// Capability flags + construction
diff --git a/test/parallel/test-vfs-zip-provider-dispose.js b/test/parallel/test-vfs-zip-provider-dispose.js
index 58331d158a4..67abb1d5bd4 100644
--- a/test/parallel/test-vfs-zip-provider-dispose.js
+++ b/test/parallel/test-vfs-zip-provider-dispose.js
@@ -9,7 +9,6 @@
const common = require('../common');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
-const path = require('path');
const fsPromises = require('fs/promises');
const zlib = require('zlib');
const vfs = require('node:vfs');
@@ -24,7 +23,7 @@ async function buildArchive(entries) {
async function writeArchive(name) {
const archive = await buildArchive([await zlib.ZipEntry.create('a.txt', Buffer.from('x'))]);
- const filePath = path.join(tmpdir.path, name);
+ const filePath = tmpdir.resolve(name);
await fsPromises.writeFile(filePath, archive);
return filePath;
}
diff --git a/test/parallel/test-vfs-zip-provider-handle.js b/test/parallel/test-vfs-zip-provider-handle.js
index 44d0505acb8..c32148e72c3 100644
--- a/test/parallel/test-vfs-zip-provider-handle.js
+++ b/test/parallel/test-vfs-zip-provider-handle.js
@@ -13,7 +13,6 @@
const common = require('../common');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
-const path = require('path');
const fs = require('fs');
const fsPromises = require('fs/promises');
const zlib = require('zlib');
@@ -414,7 +413,7 @@ function buildArchiveSync(entries, comment) {
// --- open() with a write flag against a readonly (ZipFile) archive: EROFS --
(async () => {
const archive = await buildArchive([await zlib.ZipEntry.create('a.txt', Buffer.from('x'))]);
- const filePath = path.join(tmpdir.path, 'vfs-archive-handle-readonly.zip');
+ const filePath = tmpdir.resolve('vfs-archive-handle-readonly.zip');
await fsPromises.writeFile(filePath, archive);
const zip = await zlib.ZipFile.open(filePath);
const provider = new vfs.ZipProvider(zip);
@@ -428,7 +427,7 @@ function buildArchiveSync(entries, comment) {
// --- ZipFile-backed writable archive: sync unlink/rmdir (deleteSync) ------
(async () => {
const archive = await buildArchive([await zlib.ZipEntry.create('a.txt', Buffer.from('x'))]);
- const filePath = path.join(tmpdir.path, 'vfs-archive-handle-writable-sync.zip');
+ const filePath = tmpdir.resolve('vfs-archive-handle-writable-sync.zip');
await fsPromises.writeFile(filePath, archive);
const zip = await zlib.ZipFile.open(filePath, { writable: true });
const provider = new vfs.ZipProvider(zip);
@@ -477,7 +476,7 @@ function buildArchiveSync(entries, comment) {
// O_RDWR) is rejected with EROFS, matching MemoryProvider/real fs -----------
(async () => {
const archive = await buildArchive([await zlib.ZipEntry.create('a.txt', Buffer.from('x'))]);
- const filePath = path.join(tmpdir.path, 'vfs-archive-handle-rplus-readonly.zip');
+ const filePath = tmpdir.resolve('vfs-archive-handle-rplus-readonly.zip');
await fsPromises.writeFile(filePath, archive);
const zip = await zlib.ZipFile.open(filePath); // read-only
const provider = new vfs.ZipProvider(zip);
diff --git a/test/parallel/test-vfs-zip-provider.js b/test/parallel/test-vfs-zip-provider.js
index 63982092229..c42f303c20d 100644
--- a/test/parallel/test-vfs-zip-provider.js
+++ b/test/parallel/test-vfs-zip-provider.js
@@ -10,7 +10,6 @@
const common = require('../common');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
-const path = require('path');
const fsPromises = require('fs/promises');
const zlib = require('zlib');
const vfs = require('node:vfs');
@@ -172,7 +171,7 @@ async function buildArchive(entries, comment) {
// --- ZipFile-backed, read-only: writes rejected with EROFS ----------------
{
const archive = await buildArchive([await zlib.ZipEntry.create('a.txt', Buffer.from('x'))]);
- const filePath = path.join(tmpdir.path, 'vfs-archive-readonly.zip');
+ const filePath = tmpdir.resolve('vfs-archive-readonly.zip');
await fsPromises.writeFile(filePath, archive);
const zip = await zlib.ZipFile.open(filePath);
const provider = new vfs.ZipProvider(zip);
@@ -200,7 +199,7 @@ async function buildArchive(entries, comment) {
// --- ZipFile-backed, opened writable: mutations persist to disk ----------
{
const archive = await buildArchive([await zlib.ZipEntry.create('a.txt', Buffer.from('x'))]);
- const filePath = path.join(tmpdir.path, 'vfs-archive-writable.zip');
+ const filePath = tmpdir.resolve('vfs-archive-writable.zip');
await fsPromises.writeFile(filePath, archive);
const zip = await zlib.ZipFile.open(filePath, { writable: true });
const provider = new vfs.ZipProvider(zip);
@@ -293,7 +292,7 @@ async function buildArchive(entries, comment) {
// --- ZipFile-backed via openSync: sync-only round trip on disk -----------
{
const archive = await buildArchive([await zlib.ZipEntry.create('a.txt', Buffer.from('x'))]);
- const filePath = path.join(tmpdir.path, 'vfs-archive-opensync.zip');
+ const filePath = tmpdir.resolve('vfs-archive-opensync.zip');
await fsPromises.writeFile(filePath, archive);
const zip = zlib.ZipFile.openSync(filePath, { writable: true });
const provider = new vfs.ZipProvider(zip);
diff --git a/test/parallel/test-zlib-zip-files.js b/test/parallel/test-zlib-zip-files.js
index b25dd874c70..755c1bde002 100644
--- a/test/parallel/test-zlib-zip-files.js
+++ b/test/parallel/test-zlib-zip-files.js
@@ -33,7 +33,7 @@ async function waitForAllClosed(streams) {
// so the test can observe how disposal closes every source. Their asynchronous
// opens may still be pending when the archive starts.
async function streamingEntries(count) {
- const dir = await fsp.mkdtemp(path.join(tmpdir.path, 'zlib-zip-dispose-'));
+ const dir = await fsp.mkdtemp(tmpdir.resolve('zlib-zip-dispose-'));
const streams = [];
const entries = [];
for (let i = 0; i < count; i++) {
@@ -47,7 +47,7 @@ async function streamingEntries(count) {
}
async function makeTree() {
- const dir = await fsp.mkdtemp(path.join(tmpdir.path, 'zlib-zipfiles-'));
+ const dir = await fsp.mkdtemp(tmpdir.resolve('zlib-zipfiles-'));
await fsp.writeFile(path.join(dir, 'a.txt'), 'alpha');
await fsp.chmod(path.join(dir, 'a.txt'), 0o640);
await fsp.mkdir(path.join(dir, 'sub'));
@@ -205,7 +205,7 @@ test('disposing an in-memory or file-backed entry is a harmless no-op', async ()
// A file-backed entry borrows the ZipFile's descriptor; disposing it must
// not close that descriptor.
- const dir = await fsp.mkdtemp(path.join(tmpdir.path, 'zlib-zip-dispose-fb-'));
+ const dir = await fsp.mkdtemp(tmpdir.resolve('zlib-zip-dispose-fb-'));
const archivePath = path.join(dir, 'a.zip');
try {
await fsp.writeFile(archivePath, await collect(zlib.createZipArchive(
diff --git a/test/parallel/test-zlib-zip-interop.js b/test/parallel/test-zlib-zip-interop.js
index a1c54bed178..46ade44895a 100644
--- a/test/parallel/test-zlib-zip-interop.js
+++ b/test/parallel/test-zlib-zip-interop.js
@@ -60,7 +60,7 @@ test('an archive written by createZipArchive is readable by unzip, zipinfo, and
const unzipBuild = spawnSync('unzip', ['-v'], { encoding: 'utf8' }).stdout || '';
const zipinfoUnicode = /UNICODE_SUPPORT/.test(unzipBuild);
- const dir = await fs.mkdtemp(path.join(tmpdir.path, 'zlib-zip-interop-'));
+ const dir = await fs.mkdtemp(tmpdir.resolve('zlib-zip-interop-'));
try {
const files = {
'hello.txt': Buffer.from('Hello, world!'.repeat(50)),
@@ -115,7 +115,7 @@ test('an archive written by Python\'s zipfile module is readable by ZipFile', as
return;
}
- const dir = await fs.mkdtemp(path.join(tmpdir.path, 'zlib-zip-interop-'));
+ const dir = await fs.mkdtemp(tmpdir.resolve('zlib-zip-interop-'));
try {
const archivePath = path.join(dir, 'python.zip');
const script = `
diff --git a/test/parallel/test-zlib-zip-property.js b/test/parallel/test-zlib-zip-property.js
index 0f7cf8586fd..382c9e89beb 100644
--- a/test/parallel/test-zlib-zip-property.js
+++ b/test/parallel/test-zlib-zip-property.js
@@ -63,7 +63,7 @@ async function buildTree(random, count) {
test('random archives round-trip through ZipEntry.read, ZipBuffer, and ZipFile', async () => {
const random = mulberry32(0xC0FFEE);
const rounds = 8;
- const dir = await fs.mkdtemp(path.join(tmpdir.path, 'zlib-zip-property-'));
+ const dir = await fs.mkdtemp(tmpdir.resolve('zlib-zip-property-'));
try {
for (let round = 0; round < rounds; round++) {
const { archive, specs } = await buildTree(random, 6);
diff --git a/test/parallel/test-zlib-zip-raw-content.js b/test/parallel/test-zlib-zip-raw-content.js
index f40c9919859..8fff3caa9d8 100644
--- a/test/parallel/test-zlib-zip-raw-content.js
+++ b/test/parallel/test-zlib-zip-raw-content.js
@@ -61,7 +61,7 @@ test('parsed and file-backed entries expose their raw bytes', async () => {
await assertRawReads(entry, entry.name === 'empty.txt' ? Buffer.alloc(0) : text);
}
- const dir = await fs.mkdtemp(path.join(tmpdir.path, 'zlib-zip-raw-'));
+ const dir = await fs.mkdtemp(tmpdir.resolve('zlib-zip-raw-'));
const filePath = path.join(dir, 'archive.zip');
await fs.writeFile(filePath, archive);
const zip = await zlib.ZipFile.open(filePath);
diff --git a/test/parallel/test-zlib-zip-security-hardening.js b/test/parallel/test-zlib-zip-security-hardening.js
index 83e7b6e86ac..32c228d2b12 100644
--- a/test/parallel/test-zlib-zip-security-hardening.js
+++ b/test/parallel/test-zlib-zip-security-hardening.js
@@ -19,7 +19,6 @@ const assert = require('assert');
const { test } = require('node:test');
const zlib = require('zlib');
const fs = require('fs');
-const path = require('path');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
@@ -94,7 +93,7 @@ test('failed local-header validation does not poison file-backed entries', async
buf.writeUInt32LE(zlib.crc32(decoy), centralOffset(buf) + 16);
tmpdir.refresh();
- const file = path.join(tmpdir.path, 'mismatched.zip');
+ const file = tmpdir.resolve('mismatched.zip');
fs.writeFileSync(file, buf);
const invalid = { code: 'ERR_ZIP_INVALID_ARCHIVE' };
@@ -191,7 +190,7 @@ test('failed local-header validation does not poison file-backed entries', async
test('zipFiles rejects a FIFO source instead of hanging', () => {
if (process.platform === 'win32') return; // no mkfifo
tmpdir.refresh();
- const fifo = path.join(tmpdir.path, 'evil.fifo');
+ const fifo = tmpdir.resolve('evil.fifo');
if (spawnSync('mkfifo', [fifo]).status !== 0) return; // mkfifo unavailable
const script =
'const zlib = require("zlib");' +
diff --git a/test/parallel/test-zlib-zip-security.js b/test/parallel/test-zlib-zip-security.js
index aa4b37f4c60..10f63497444 100644
--- a/test/parallel/test-zlib-zip-security.js
+++ b/test/parallel/test-zlib-zip-security.js
@@ -18,7 +18,7 @@ tmpdir.refresh();
let seq = 0;
async function tempZip(entries) {
- const dir = await fsp.mkdtemp(path.join(tmpdir.path, `zip-sec-${seq++}-`));
+ const dir = await fsp.mkdtemp(tmpdir.resolve(`zip-sec-${seq++}-`));
const chunks = [];
for await (const chunk of zlib.createZipArchive(entries)) chunks.push(chunk);
const filePath = path.join(dir, 'archive.zip');
@@ -219,7 +219,7 @@ test('open() rejects contradictory classic-EOCD vs Zip64 metadata', async () =>
assert.throws(() => new zlib.ZipBuffer(tampered), { code: 'ERR_ZIP_INVALID_ARCHIVE' });
- const dir = await fsp.mkdtemp(path.join(tmpdir.path, `zip-sec-${seq++}-`));
+ const dir = await fsp.mkdtemp(tmpdir.resolve(`zip-sec-${seq++}-`));
const p = path.join(dir, 'contradiction.zip');
try {
await fsp.writeFile(p, tampered);
@@ -253,7 +253,7 @@ test('central-directory record count must account for its full declared size', a
assert.throws(() => [...zlib.ZipEntry.read(tampered)], expected);
assert.throws(() => new zlib.ZipBuffer(tampered), expected);
- const dir = await fsp.mkdtemp(path.join(tmpdir.path, `zip-sec-${seq++}-`));
+ const dir = await fsp.mkdtemp(tmpdir.resolve(`zip-sec-${seq++}-`));
const p = path.join(dir, 'record-count-mismatch.zip');
try {
await fsp.writeFile(p, tampered);
@@ -287,7 +287,7 @@ test('ZipFile.open() enforces the same member-overlap check as ZipBuffer', async
// The file-backed reader must reject it too, at open time - not silently
// accept an archive whose members overlap.
- const dir = await fsp.mkdtemp(path.join(tmpdir.path, `zip-sec-${seq++}-`));
+ const dir = await fsp.mkdtemp(tmpdir.resolve(`zip-sec-${seq++}-`));
const p = path.join(dir, 'overlap.zip');
try {
await fsp.writeFile(p, tampered);
diff --git a/test/parallel/test-zlib-zip-sync.js b/test/parallel/test-zlib-zip-sync.js
index 1f7099849b9..9b5769fb92d 100644
--- a/test/parallel/test-zlib-zip-sync.js
+++ b/test/parallel/test-zlib-zip-sync.js
@@ -18,7 +18,7 @@ function buildArchiveSync(entries, comment) {
}
function createTempZipSync(entries, comment) {
- const dir = fs.mkdtempSync(path.join(tmpdir.path, 'zlib-zip-sync-'));
+ const dir = fs.mkdtempSync(tmpdir.resolve('zlib-zip-sync-'));
const filePath = path.join(dir, 'archive.zip');
fs.writeFileSync(filePath, buildArchiveSync(entries, comment));
return { filePath, cleanup: () => fs.rmSync(dir, { recursive: true, force: true }) };
diff --git a/test/parallel/test-zlib-zip-writable.js b/test/parallel/test-zlib-zip-writable.js
index 5beb4751ad7..caa2044ba14 100644
--- a/test/parallel/test-zlib-zip-writable.js
+++ b/test/parallel/test-zlib-zip-writable.js
@@ -18,7 +18,7 @@ async function buildArchive(entries, comment) {
}
async function createTempZip(entries, comment) {
- const dir = await fs.mkdtemp(path.join(tmpdir.path, 'zlib-zip-writable-'));
+ const dir = await fs.mkdtemp(tmpdir.resolve('zlib-zip-writable-'));
const filePath = path.join(dir, 'archive.zip');
await fs.writeFile(filePath, await buildArchive(entries, comment));
return { filePath, cleanup: () => fs.rm(dir, { recursive: true, force: true }) };
diff --git a/test/pummel/test-zlib-zip-slow.js b/test/pummel/test-zlib-zip-slow.js
index ab023456890..c68f3a19031 100644
--- a/test/pummel/test-zlib-zip-slow.js
+++ b/test/pummel/test-zlib-zip-slow.js
@@ -59,7 +59,7 @@ test('an archive larger than 4 GiB round-trips and triggers Zip64 via offset', a
return;
}
- const dir = await fs.mkdtemp(path.join(tmpdir.path, 'zlib-zip-slow-'));
+ const dir = await fs.mkdtemp(tmpdir.resolve('zlib-zip-slow-'));
const archivePath = path.join(dir, 'large.zip');
try {
const entries = [
diff --git a/test/sea/test-single-executable-application-vfs-code-cache.js b/test/sea/test-single-executable-application-vfs-code-cache.js
index 78893687961..c041557c7b4 100644
--- a/test/sea/test-single-executable-application-vfs-code-cache.js
+++ b/test/sea/test-single-executable-application-vfs-code-cache.js
@@ -20,7 +20,6 @@ skipIfSigningIsNotSupported();
const assert = require('assert');
const fs = require('fs');
-const path = require('path');
const { createWriteStream } = require('fs');
const { pipeline } = require('stream/promises');
const { zipFiles } = require('zlib');
@@ -93,7 +92,7 @@ async function main() {
cwd: tmpdir.path,
env: {
...process.env,
- NODE_COMPILE_CACHE: path.join(tmpdir.path, 'config.json', 'nope'),
+ NODE_COMPILE_CACHE: tmpdir.resolve('config.json', 'nope'),
NODE_DISABLE_COMPILE_CACHE: '1',
NODE_DEBUG_NATIVE: undefined,
},