From 29ec7d1469e6fd7a51d68c8cd175ebe04b1b44a9 Mon Sep 17 00:00:00 2001 From: plondon Date: Sun, 24 Oct 2021 16:17:13 -0400 Subject: [PATCH] Wait for code to finish w/ crappy set timeout 3 --- backend/api.js | 10 ++++++++-- frontend/src/app.js | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/api.js b/backend/api.js index 5a372ba..4646a00 100644 --- a/backend/api.js +++ b/backend/api.js @@ -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, }); } diff --git a/frontend/src/app.js b/frontend/src/app.js index a0127bd..2d78612 100644 --- a/frontend/src/app.js +++ b/frontend/src/app.js @@ -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"