Skip to content

Commit

Permalink
test: describeIf and testIf utilities for conditional testing
Browse files Browse the repository at this point in the history
  • Loading branch information
emmacasolin committed Jun 13, 2022
1 parent f3d63c9 commit 08209b2
Show file tree
Hide file tree
Showing 9 changed files with 1,772 additions and 1,182 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"node-gyp-build": "4.4.0",
"pkg": "5.6.0",
"prettier": "^2.6.2",
"shelljs": "^0.8.5",
"shx": "^0.3.4",
"ts-jest": "^27.0.5",
"ts-node": "^10.4.0",
Expand Down
1 change: 0 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ in
utils.node2nix
grpc-tools
grpcurl
iptables-legacy
];
PKG_CACHE_PATH = utils.pkgCachePath;
PKG_IGNORE_TAG = 1;
Expand Down
30 changes: 30 additions & 0 deletions tests/bin/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,35 @@ import nexpect from 'nexpect';
import Logger from '@matrixai/logger';
import main from '@/bin/polykey';

/**
* Wrapper for execFile to make it asynchronous and non-blocking
*/
async function exec(
command: string,
args: Array<string> = [],
): Promise<{
stdout: string;
stderr: string;
}> {
return new Promise((resolve, reject) => {
child_process.execFile(
command,
args,
{ windowsHide: true },
(error, stdout, stderr) => {
if (error) {
reject(error);
} else {
return resolve({
stdout,
stderr,
});
}
},
);
});
}

/**
* Runs pk command functionally
*/
Expand Down Expand Up @@ -361,6 +390,7 @@ function expectProcessError(
}

export {
exec,
pk,
pkStdio,
pkExec,
Expand Down
Loading

0 comments on commit 08209b2

Please sign in to comment.