diff --git a/backend/src/langs.ts b/backend/src/langs.ts index fcd16f7..d419488 100644 --- a/backend/src/langs.ts +++ b/backend/src/langs.ts @@ -592,7 +592,7 @@ Start world }, template: `echo "Hello, world!" `, - timeout: 15, + timeout: 30, }, cobol: { aliases: ["cbl", "cobc"], diff --git a/backend/src/test-runner.ts b/backend/src/test-runner.ts index fad3ba9..999ee83 100644 --- a/backend/src/test-runner.ts +++ b/backend/src/test-runner.ts @@ -3,6 +3,8 @@ import * as process from "process"; import { promisify } from "util"; import * as _ from "lodash"; +import { Moment } from "moment"; +import * as moment from "moment"; import PQueue from "p-queue"; import * as rimraf from "rimraf"; import { v4 as getUUID } from "uuid"; @@ -47,6 +49,7 @@ class Test { timedOut: boolean = false; handledMessages: number = 0; handleUpdate: () => void = () => {}; + startTime: Moment | null = null; get config() { return langs[this.lang]; @@ -54,9 +57,14 @@ class Test { ws: any = null; + record = (msg: any) => { + const dur = moment.duration(moment().diff(this.startTime!)); + this.messages.push({ time: dur.asSeconds(), ...msg }); + }; + send = (msg: any) => { this.ws.onMessage(JSON.stringify(msg)); - this.messages.push(msg); + this.record(msg); this.handledMessages += 1; }; @@ -76,6 +84,7 @@ class Test { if ((this.config.skip || []).includes(this.type)) { return "skipped"; } + this.startTime = moment(); let session = null; let timeout = null; try { @@ -103,13 +112,13 @@ class Test { }, messageQueue: [] as any[], send: function (data: string) { - that.messages.push(JSON.parse(data)); + that.record(JSON.parse(data)); that.handleUpdate(); }, terminate: function () {}, }; session = new api.Session(this.ws, this.lang, (msg: string) => { - this.messages.push({ event: "serverLog", message: msg }); + this.record({ event: "serverLog", message: msg }); }); timeout = setTimeout(() => { this.timedOut = true; diff --git a/package.json b/package.json index fd1b757..c58174e 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "file-loader": "^6.0.0", "historic-readline": "^1.0.8", "lodash": "^4.17.15", + "moment": "^2.27.0", "monaco-editor": "^0.20.0", "monaco-editor-webpack-plugin": "^1.9.0", "monaco-languageclient": "^0.13.0", diff --git a/yarn.lock b/yarn.lock index 045d049..27ba20a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3374,6 +3374,11 @@ mocha@^5.2.0: mkdirp "0.5.1" supports-color "5.4.0" +moment@^2.27.0: + version "2.27.0" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.27.0.tgz#8bff4e3e26a236220dfe3e36de756b6ebaa0105d" + integrity sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ== + monaco-editor-webpack-plugin@^1.9.0: version "1.9.0" resolved "https://registry.yarnpkg.com/monaco-editor-webpack-plugin/-/monaco-editor-webpack-plugin-1.9.0.tgz#5b547281b9f404057dc5d8c5722390df9ac90be6"