diff --git a/test/common/README.md b/test/common/README.md index a941d531391e8c..86c6e4208a648d 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -1027,6 +1027,13 @@ Avoid calling it more than once in an asynchronous context as one call might refresh the temporary directory of a different context, causing the test to fail somewhat mysteriously. +### `resolve([...paths])` + +* `...paths` [\][] +* return [\][] + +Resolves a sequence of paths into absolute path in the temporary directory. + ### `hasEnoughSpace(size)` * `size` [\][] Required size, in bytes. diff --git a/test/common/tmpdir.js b/test/common/tmpdir.js index 94e6a4552a4fa6..decfa97a892771 100644 --- a/test/common/tmpdir.js +++ b/test/common/tmpdir.js @@ -55,6 +55,10 @@ function onexit() { } } +function resolve(...paths) { + return path.resolve(tmpPath, ...paths); +} + function hasEnoughSpace(size) { const { bavail, bsize } = fs.statfsSync(tmpPath); return bavail >= Math.ceil(size / bsize); @@ -64,4 +68,5 @@ module.exports = { path: tmpPath, refresh, hasEnoughSpace, + resolve, };