Misc bugfixes for runner and test cases

This commit is contained in:
Radon Rosborough 2020-07-30 15:48:30 -06:00
parent da7940061f
commit 97e2099226
4 changed files with 28 additions and 17 deletions

View File

@ -15,6 +15,7 @@ export interface LangConfig {
run: string;
helloInput?: string;
hello?: string;
helloMaxLength?: number;
runReplInput?: string;
runReplOutput?: string;
scope?: {
@ -675,6 +676,8 @@ output = "Hello, world!"
main: "main.vge",
compile: `mono /opt/entropy/entc.exe main.vge | grep -Ev 'WARNING:|Using default' > main.cs && mcs -lib:/opt/entropy -r:Rottytooth.Esolang.Entropy main.cs`,
run: "MONO_PATH=/opt/entropy mono main.exe",
hello: `[F-J][c-g][j-n][j-n][m-q][*-.][\\x1e-"][u-y][m-q][p-t][j-n][b-f][\\x1f-#]`,
helloMaxLength: "Hello, world!".length,
template: `Program MyNamespace MyProgram [
print "Hello, world!";
]
@ -896,7 +899,7 @@ log('Hello, world!')
aliases: ["i", "ick"],
name: "INTERCAL",
main: "main.i",
compile: "ick main.i",
compile: "ick -b main.i",
run: "./main",
template: `DO ,1 <- #14
PLEASE DO ,1 SUB #1 <- #238
@ -1016,7 +1019,6 @@ PLEASE GIVE UP
name: "LiveScript",
repl: "lsc",
main: "main.ls",
hello: "Hello World",
run: "lsc -r ./main.ls; lsc",
template: `console.log "Hello, world!"
`,
@ -1063,6 +1065,7 @@ KTHXBYE
name: "Malbolge",
main: "main.mb",
run: "malbolge main.mb",
hello: "Hello World!",
template:
" (=<`#9]~6ZY32Vx/4Rs+0No-&Jk)\"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc\n",
},
@ -1302,7 +1305,6 @@ end.
repl: "php -a",
input: "print 123 * 234;",
main: "main.php",
hello: "Hello World!",
run: "php -d auto_prepend_file=main.php -a",
lsp: { start: "intelephense --stdio" },
template: `<?php
@ -1326,6 +1328,7 @@ echo "Hello, world!\\n";
name: "Pikachu",
main: "main.pokeball",
run: "pikalang main.pokeball",
hello: "Hello World!",
template: `pi pi pi pi pi pi pi pi pi pi pika pipi pi pi pi pi pi pi pi pipi pi pi
pi pi pi pi pi pi pi pi pipi pi pi pi pipi pi pichu pichu pichu pichu ka
chu pipi pi pi pikachu pipi pi pikachu pi pi pi pi pi pi pi pikachu

View File

@ -10,8 +10,8 @@ import { v4 as getUUID } from "uuid";
import * as api from "./api";
import { LangConfig, langs } from "./langs";
const TIMEOUT_MS = 5000;
const CONCURRENCY = 32;
const TIMEOUT_MS = 10000;
const CONCURRENCY = 16;
function findPosition(str: string, idx: number) {
const lines = str.substring(0, idx).split("\n");
@ -101,8 +101,8 @@ class Test {
case "ensure":
await this.testEnsure();
break;
case "hello":
await this.testHello();
case "run":
await this.testRun();
break;
case "repl":
await this.testRepl();
@ -153,14 +153,22 @@ class Test {
});
};
waitForOutput = async (pattern: string) => {
waitForOutput = async (pattern: string, maxLength?: number) => {
let output = "";
return await this.wait(`output ${JSON.stringify(pattern)}`, (msg: any) => {
const prevLength = output.length;
if (msg.event === "terminalOutput") {
output += msg.output;
}
return output.indexOf(pattern, prevLength - pattern.length) != -1;
if (typeof maxLength === "number") {
return (
output
.substring(prevLength - maxLength)
.match(new RegExp(pattern)) !== null
);
} else {
return output.indexOf(pattern, prevLength - pattern.length) != -1;
}
});
};
@ -175,7 +183,7 @@ class Test {
throw new Error(`ensure failed with code ${code}`);
}
};
testHello = async () => {
testRun = async () => {
const pattern = this.config.hello || "Hello, world!";
this.send({ event: "runCode", code: this.config.template });
if (this.config.helloInput !== undefined) {
@ -184,7 +192,7 @@ class Test {
input: forTTY(this.config.helloInput),
});
}
await this.waitForOutput(pattern);
await this.waitForOutput(pattern, this.config.helloMaxLength);
};
testRepl = async () => {
const input = this.config.input || "123 * 234";
@ -547,7 +555,7 @@ const testTypes: {
ensure: {
pred: ({ ensure }) => (ensure ? true : false),
},
hello: { pred: (config) => true },
run: { pred: (config) => true },
repl: {
pred: ({ repl }) => (repl ? true : false),
},
@ -653,8 +661,7 @@ async function main() {
`FAILED: ${lang}/${type}\n` +
test.getLog({ pretty: true }) +
"\n" +
err.stack +
"\n"
(err.stack ? err.stack + "\n" : err ? `${err}` : "")
);
})
.catch(console.error);
@ -671,8 +678,8 @@ async function main() {
if (failed.size > 0) {
console.error(`${failed.size} test${failed.size !== 1 ? "s" : ""} FAILED`);
_.sortBy(Array.from(failed), [
"lang",
"type",
([{ lang }, _]: any) => lang,
([{ type }, _]: any) => type,
]).forEach(([{ lang, type }, err]) =>
console.error(` - ${lang}/${type} (${err})`)
);

View File

@ -61,6 +61,6 @@
"dev": "run-p backend-dev frontend-dev system-dev server-dev",
"lsp-repl": "node backend/out/lsp-repl.js",
"sandbox": "node backend/out/sandbox.js",
"test": "bash -c 'time node backend/out/test-runner.js'"
"test": "bash -c 'time node backend/out/test-runner.js \"$@\"' --"
}
}

View File

@ -1,5 +1,6 @@
{
"compilerOptions": {
"downlevelIteration": true,
"outDir": "./backend/out",
"resolveJsonModule": true,
"rootDir": "./backend/src",