Skip to content

Commit

Permalink
test: add tmpdir.resolve()
Browse files Browse the repository at this point in the history
PR-URL: #49079
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
  • Loading branch information
LiviaMedeiros authored and richardlau committed Sep 28, 2023
1 parent 779043d commit 04cba95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` [\<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.
Expand Down
5 changes: 5 additions & 0 deletions test/common/tmpdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -64,4 +68,5 @@ module.exports = {
path: tmpPath,
refresh,
hasEnoughSpace,
resolve,
};

0 comments on commit 04cba95

Please sign in to comment.