Skip to content

Commit 08209b2

Browse files
committed
test: describeIf and testIf utilities for conditional testing
1 parent f3d63c9 commit 08209b2

9 files changed

Lines changed: 1772 additions & 1182 deletions

File tree

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
"node-gyp-build": "4.4.0",
138138
"pkg": "5.6.0",
139139
"prettier": "^2.6.2",
140+
"shelljs": "^0.8.5",
140141
"shx": "^0.3.4",
141142
"ts-jest": "^27.0.5",
142143
"ts-node": "^10.4.0",

shell.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ in
1010
utils.node2nix
1111
grpc-tools
1212
grpcurl
13-
iptables-legacy
1413
];
1514
PKG_CACHE_PATH = utils.pkgCachePath;
1615
PKG_IGNORE_TAG = 1;

tests/bin/utils.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,35 @@ import nexpect from 'nexpect';
1212
import Logger from '@matrixai/logger';
1313
import main from '@/bin/polykey';
1414

15+
/**
16+
* Wrapper for execFile to make it asynchronous and non-blocking
17+
*/
18+
async function exec(
19+
command: string,
20+
args: Array<string> = [],
21+
): Promise<{
22+
stdout: string;
23+
stderr: string;
24+
}> {
25+
return new Promise((resolve, reject) => {
26+
child_process.execFile(
27+
command,
28+
args,
29+
{ windowsHide: true },
30+
(error, stdout, stderr) => {
31+
if (error) {
32+
reject(error);
33+
} else {
34+
return resolve({
35+
stdout,
36+
stderr,
37+
});
38+
}
39+
},
40+
);
41+
});
42+
}
43+
1544
/**
1645
* Runs pk command functionally
1746
*/
@@ -361,6 +390,7 @@ function expectProcessError(
361390
}
362391

363392
export {
393+
exec,
364394
pk,
365395
pkStdio,
366396
pkExec,

0 commit comments

Comments
 (0)