test: allow tmpDir.path to be modified

PR-URL: https://github.com/nodejs/node/pull/58173
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Aviv Keller 2025-05-12 14:43:02 -04:00 committed by GitHub
parent 292263e378
commit 563be01292
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -39,7 +39,7 @@ const testRoot = process.env.NODE_TEST_DIR ?
// gets tools to ignore it by default or by simple rules, especially eslint. // gets tools to ignore it by default or by simple rules, especially eslint.
const tmpdirName = '.tmp.' + const tmpdirName = '.tmp.' +
(process.env.TEST_SERIAL_ID || process.env.TEST_THREAD_ID || '0'); (process.env.TEST_SERIAL_ID || process.env.TEST_THREAD_ID || '0');
const tmpPath = path.join(testRoot, tmpdirName); let tmpPath = path.join(testRoot, tmpdirName);
let firstRefresh = true; let firstRefresh = true;
function refresh(useSpawn = false) { function refresh(useSpawn = false) {
@ -100,7 +100,13 @@ function fileURL(...paths) {
module.exports = { module.exports = {
fileURL, fileURL,
hasEnoughSpace, hasEnoughSpace,
path: tmpPath,
refresh, refresh,
resolve, resolve,
get path() {
return tmpPath;
},
set path(newPath) {
tmpPath = path.resolve(newPath);
},
}; };