-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_runner.js
49 lines (39 loc) · 1.27 KB
/
test_runner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const { exec, ChildProcessWithoutNullStreams, spawn } = require("child_process");
class CommandRunner {
// cmdString: string
// childProcess_: ChildProcessWithoutNullStreams
// onResolve_;
// onReject_;
constructor(cmd) {
this.cmdString = cmd;
// this.event = new EventEmitter();
}
run() {
return new Promise((res, rej) => {
this.onResolve_ = res;
this.onReject_ = rej;
this.childProcess_ = spawn(this.cmdString, {
detached: true,
stdio: 'pipe',
shell: true
});
//exec(this.cmdString);
this.childProcess_.stdout.on('data', (data) => {
console.log("data", data.toString())
});
this.childProcess_.stderr.on('data', (data) => {
console.log("error", data.toString())
});
this.childProcess_.on("error", (err) => {
rej(err);
})
this.childProcess_.on('exit', (code) => {
res(code);
});
})
}
async quit() {
process.kill(-this.childProcess_.pid);
}
}
new CommandRunner("cd tests/general && CRYSTAL_ENV=TEST crystal spec e2e/* --error-trace").run();