Wait for code to finish w/ crappy set timeout 3

This commit is contained in:
plondon 2021-10-24 16:17:13 -04:00
parent e65a79bfed
commit 29ec7d1469
2 changed files with 14 additions and 3 deletions

View File

@ -12,7 +12,7 @@ import * as util from "./util.js";
import { bash, getUUID, logError } from "./util.js"; import { bash, getUUID, logError } from "./util.js";
const allSessions = new Set(); const allSessions = new Set();
export const TEST_RUN_FINISHED = "Test run finished!\n"; export const TEST_RUN_FINISHED = "Test run!\n";
export class Session { export class Session {
get homedir() { get homedir() {
return "/home/riju/src"; return "/home/riju/src";
@ -235,7 +235,11 @@ export class Session {
break; break;
} }
await this.runCode(msg.code, msg.expectedOutput); await this.runCode(msg.code, msg.expectedOutput);
this.term.pty.stdin.write(TEST_RUN_FINISHED); if (!this.config.repl) {
setTimeout(() => {
this.term.pty.stdin.write(TEST_RUN_FINISHED);
});
}
break; break;
case "formatCode": case "formatCode":
if (typeof msg.code !== "string") { if (typeof msg.code !== "string") {
@ -273,6 +277,7 @@ export class Session {
break; break;
} }
} catch (err) { } catch (err) {
console.log(err);
logError(err); logError(err);
this.sendError(err); this.sendError(err);
} }
@ -353,6 +358,7 @@ export class Session {
event: "serviceFailed", event: "serviceFailed",
service: "terminal", service: "terminal",
error: `Exited with status ${signal || code}`, error: `Exited with status ${signal || code}`,
expectedOutput,
code: signal || code, code: signal || code,
}); });
} }

View File

@ -152,7 +152,7 @@ async function main() {
term.write(message.output); term.write(message.output);
testData.push(message.output); testData.push(message.output);
if (testData.join("").includes('Test run finished')) { if (testData.join("").includes('Test run')) {
postTestResults(testData, message.expectedOutput); postTestResults(testData, message.expectedOutput);
testData = []; testData = [];
} }
@ -201,6 +201,11 @@ async function main() {
serviceLogLines[message.service] = lines; serviceLogLines[message.service] = lines;
return; return;
case "serviceFailed": case "serviceFailed":
if (expectedOutput) {
postTestResults(testData, expectedOutput)
testData = []
}
if ( if (
typeof message.service !== "string" || typeof message.service !== "string" ||
typeof message.error !== "string" typeof message.error !== "string"