From 13bd7a02939fd7a0a03c1e469aeec49a04648d66 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 d4279e00af68b5..db56e4744dd1b1 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -1062,6 +1062,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 c3858765e01985..f1f06818dc46d2 100644 --- a/test/common/tmpdir.js +++ b/test/common/tmpdir.js @@ -70,6 +70,10 @@ function onexit(useSpawn) { } } +function resolve(...paths) { + return path.resolve(tmpPath, ...paths); +} + function hasEnoughSpace(size) { const { bavail, bsize } = fs.statfsSync(tmpPath); return bavail >= Math.ceil(size / bsize); @@ -87,4 +91,5 @@ module.exports = { hasEnoughSpace, path: tmpPath, refresh, + resolve, };