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";
const allSessions = new Set();
export const TEST_RUN_FINISHED = "Test run finished!\n";
export const TEST_RUN_FINISHED = "Test run!\n";
export class Session {
get homedir() {
return "/home/riju/src";
@ -235,7 +235,11 @@ export class Session {
break;
}
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;
case "formatCode":
if (typeof msg.code !== "string") {
@ -273,6 +277,7 @@ export class Session {
break;
}
} catch (err) {
console.log(err);
logError(err);
this.sendError(err);
}
@ -353,6 +358,7 @@ export class Session {
event: "serviceFailed",
service: "terminal",
error: `Exited with status ${signal || code}`,
expectedOutput,
code: signal || code,
});
}

View File

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