[#34] Show timing info for tests, bump Cmd timeout

This commit is contained in:
Radon Rosborough 2020-09-02 08:26:38 -06:00
parent 84707457fc
commit 8222937a06
4 changed files with 19 additions and 4 deletions

View File

@ -592,7 +592,7 @@ Start world
}, },
template: `echo "Hello, world!" template: `echo "Hello, world!"
`, `,
timeout: 15, timeout: 30,
}, },
cobol: { cobol: {
aliases: ["cbl", "cobc"], aliases: ["cbl", "cobc"],

View File

@ -3,6 +3,8 @@ import * as process from "process";
import { promisify } from "util"; import { promisify } from "util";
import * as _ from "lodash"; import * as _ from "lodash";
import { Moment } from "moment";
import * as moment from "moment";
import PQueue from "p-queue"; import PQueue from "p-queue";
import * as rimraf from "rimraf"; import * as rimraf from "rimraf";
import { v4 as getUUID } from "uuid"; import { v4 as getUUID } from "uuid";
@ -47,6 +49,7 @@ class Test {
timedOut: boolean = false; timedOut: boolean = false;
handledMessages: number = 0; handledMessages: number = 0;
handleUpdate: () => void = () => {}; handleUpdate: () => void = () => {};
startTime: Moment | null = null;
get config() { get config() {
return langs[this.lang]; return langs[this.lang];
@ -54,9 +57,14 @@ class Test {
ws: any = null; ws: any = null;
record = (msg: any) => {
const dur = moment.duration(moment().diff(this.startTime!));
this.messages.push({ time: dur.asSeconds(), ...msg });
};
send = (msg: any) => { send = (msg: any) => {
this.ws.onMessage(JSON.stringify(msg)); this.ws.onMessage(JSON.stringify(msg));
this.messages.push(msg); this.record(msg);
this.handledMessages += 1; this.handledMessages += 1;
}; };
@ -76,6 +84,7 @@ class Test {
if ((this.config.skip || []).includes(this.type)) { if ((this.config.skip || []).includes(this.type)) {
return "skipped"; return "skipped";
} }
this.startTime = moment();
let session = null; let session = null;
let timeout = null; let timeout = null;
try { try {
@ -103,13 +112,13 @@ class Test {
}, },
messageQueue: [] as any[], messageQueue: [] as any[],
send: function (data: string) { send: function (data: string) {
that.messages.push(JSON.parse(data)); that.record(JSON.parse(data));
that.handleUpdate(); that.handleUpdate();
}, },
terminate: function () {}, terminate: function () {},
}; };
session = new api.Session(this.ws, this.lang, (msg: string) => { 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(() => { timeout = setTimeout(() => {
this.timedOut = true; this.timedOut = true;

View File

@ -28,6 +28,7 @@
"file-loader": "^6.0.0", "file-loader": "^6.0.0",
"historic-readline": "^1.0.8", "historic-readline": "^1.0.8",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"moment": "^2.27.0",
"monaco-editor": "^0.20.0", "monaco-editor": "^0.20.0",
"monaco-editor-webpack-plugin": "^1.9.0", "monaco-editor-webpack-plugin": "^1.9.0",
"monaco-languageclient": "^0.13.0", "monaco-languageclient": "^0.13.0",

View File

@ -3374,6 +3374,11 @@ mocha@^5.2.0:
mkdirp "0.5.1" mkdirp "0.5.1"
supports-color "5.4.0" 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: monaco-editor-webpack-plugin@^1.9.0:
version "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" resolved "https://registry.yarnpkg.com/monaco-editor-webpack-plugin/-/monaco-editor-webpack-plugin-1.9.0.tgz#5b547281b9f404057dc5d8c5722390df9ac90be6"