mirror of https://github.com/nodejs/node.git
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>pull/49125/head
parent
dde8510e83
commit
a4928b069b
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue