From c59cc3ef4c7b509481c34cbba3392d55c6ed5945 Mon Sep 17 00:00:00 2001 From: LiviaMedeiros Date: Wed, 9 Aug 2023 18:51:25 +0800 Subject: [PATCH] test: add `tmpdir.resolve()` --- 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 515e92325edb4d..b4ffd2f7c9fbb8 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -1056,6 +1056,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, };