Skip to content

Commit

Permalink
Report error with stderr out when stream closes
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Marr <git@stefan-marr.de>
  • Loading branch information
smarr committed May 4, 2017
1 parent df16b39 commit 47da7b2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions tools/kompos/tests/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,23 @@ export class TestConnection extends VmConnection {
const promise = new Promise((resolve, reject) => {
this.connectionResolver = resolve;
let connecting = false;
let errOut = "";

this.somProc.on("exit", (code, signal) => {
if (code !== 0) {
reject(new Error("Process exited with code: " + code + " Signal: " + signal));
this.somProc.stderr.on("close", () => {
reject(new Error("Process exited with code: " + code + " Signal: " + signal + " StdErr: " + errOut));
});
}
});

if (PRINT_SOM_OUTPUT) {
this.somProc.stderr.on("data", (data) => { console.error(data.toString()); });
}
this.somProc.stderr.on("data", data => {
const dataStr = data.toString();
if (PRINT_SOM_OUTPUT) {
console.error(dataStr);
}
errOut += dataStr;
});

this.somProc.stdout.on("data", (data) => {
const dataStr = data.toString();
Expand All @@ -101,7 +108,9 @@ export class TestConnection extends VmConnection {
this.connect();
}
if (dataStr.includes("Failed starting WebSocket and/or HTTP Server")) {
reject(new Error("SOMns failed to starting WebSocket and/or HTTP Server. Output: " + dataStr));
this.somProc.stderr.on("close", () => {
reject(new Error("SOMns failed to starting WebSocket and/or HTTP Server. StdOut: " + dataStr + " StdErr: " + errOut));
});
}
});
});
Expand Down

0 comments on commit 47da7b2

Please sign in to comment.