test: add tmpdir.resolve()

PR-URL: https://github.com/nodejs/node/pull/49079
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
Livia Medeiros
2023-08-13 10:39:34 +09:00
committed by GitHub
parent dde8510e83
commit a4928b069b
2 changed files with 12 additions and 0 deletions

View File

@@ -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` [\<string>][<string>]
* return [\<string>][<string>]
Resolves a sequence of paths into absolute path in the temporary directory.
### `hasEnoughSpace(size)`
* `size` [\<number>][<number>] Required size, in bytes.

View File

@@ -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,
};