From 04cba95a67872d66583165d556ca7de759e26a29 Mon Sep 17 00:00:00 2001 From: Livia Medeiros Date: Sun, 13 Aug 2023 10:39:34 +0900 Subject: [PATCH] test: add `tmpdir.resolve()` PR-URL: https://github.com/nodejs/node/pull/49079 Reviewed-By: Antoine du Hamel Reviewed-By: Joyee Cheung --- test/common/README.md | 7 +++++++ test/common/tmpdir.js | 5 +++++ 2 files changed, 12 insertions(+) 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, };