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 <duhamelantoine1995@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
LiviaMedeiros authored and RafaelGSS committed Aug 17, 2023
1 parent 89b1bce commit 13bd7a0
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 @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions test/common/tmpdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -87,4 +91,5 @@ module.exports = {
hasEnoughSpace,
path: tmpPath,
refresh,
resolve,
};

0 comments on commit 13bd7a0

Please sign in to comment.