Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add tmpdir.resolve() #49079

Merged
merged 1 commit into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` [\<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,
};