Misc bugfixes for runner and test cases
This commit is contained in:
parent
da7940061f
commit
97e2099226
|
@ -15,6 +15,7 @@ export interface LangConfig {
|
||||||
run: string;
|
run: string;
|
||||||
helloInput?: string;
|
helloInput?: string;
|
||||||
hello?: string;
|
hello?: string;
|
||||||
|
helloMaxLength?: number;
|
||||||
runReplInput?: string;
|
runReplInput?: string;
|
||||||
runReplOutput?: string;
|
runReplOutput?: string;
|
||||||
scope?: {
|
scope?: {
|
||||||
|
@ -675,6 +676,8 @@ output = "Hello, world!"
|
||||||
main: "main.vge",
|
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`,
|
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",
|
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 [
|
template: `Program MyNamespace MyProgram [
|
||||||
print "Hello, world!";
|
print "Hello, world!";
|
||||||
]
|
]
|
||||||
|
@ -896,7 +899,7 @@ log('Hello, world!')
|
||||||
aliases: ["i", "ick"],
|
aliases: ["i", "ick"],
|
||||||
name: "INTERCAL",
|
name: "INTERCAL",
|
||||||
main: "main.i",
|
main: "main.i",
|
||||||
compile: "ick main.i",
|
compile: "ick -b main.i",
|
||||||
run: "./main",
|
run: "./main",
|
||||||
template: `DO ,1 <- #14
|
template: `DO ,1 <- #14
|
||||||
PLEASE DO ,1 SUB #1 <- #238
|
PLEASE DO ,1 SUB #1 <- #238
|
||||||
|
@ -1016,7 +1019,6 @@ PLEASE GIVE UP
|
||||||
name: "LiveScript",
|
name: "LiveScript",
|
||||||
repl: "lsc",
|
repl: "lsc",
|
||||||
main: "main.ls",
|
main: "main.ls",
|
||||||
hello: "Hello World",
|
|
||||||
run: "lsc -r ./main.ls; lsc",
|
run: "lsc -r ./main.ls; lsc",
|
||||||
template: `console.log "Hello, world!"
|
template: `console.log "Hello, world!"
|
||||||
`,
|
`,
|
||||||
|
@ -1063,6 +1065,7 @@ KTHXBYE
|
||||||
name: "Malbolge",
|
name: "Malbolge",
|
||||||
main: "main.mb",
|
main: "main.mb",
|
||||||
run: "malbolge main.mb",
|
run: "malbolge main.mb",
|
||||||
|
hello: "Hello World!",
|
||||||
template:
|
template:
|
||||||
" (=<`#9]~6ZY32Vx/4Rs+0No-&Jk)\"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc\n",
|
" (=<`#9]~6ZY32Vx/4Rs+0No-&Jk)\"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc\n",
|
||||||
},
|
},
|
||||||
|
@ -1302,7 +1305,6 @@ end.
|
||||||
repl: "php -a",
|
repl: "php -a",
|
||||||
input: "print 123 * 234;",
|
input: "print 123 * 234;",
|
||||||
main: "main.php",
|
main: "main.php",
|
||||||
hello: "Hello World!",
|
|
||||||
run: "php -d auto_prepend_file=main.php -a",
|
run: "php -d auto_prepend_file=main.php -a",
|
||||||
lsp: { start: "intelephense --stdio" },
|
lsp: { start: "intelephense --stdio" },
|
||||||
template: `<?php
|
template: `<?php
|
||||||
|
@ -1326,6 +1328,7 @@ echo "Hello, world!\\n";
|
||||||
name: "Pikachu",
|
name: "Pikachu",
|
||||||
main: "main.pokeball",
|
main: "main.pokeball",
|
||||||
run: "pikalang 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
|
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
|
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
|
chu pipi pi pi pikachu pipi pi pikachu pi pi pi pi pi pi pi pikachu
|
||||||
|
|
|
@ -10,8 +10,8 @@ import { v4 as getUUID } from "uuid";
|
||||||
import * as api from "./api";
|
import * as api from "./api";
|
||||||
import { LangConfig, langs } from "./langs";
|
import { LangConfig, langs } from "./langs";
|
||||||
|
|
||||||
const TIMEOUT_MS = 5000;
|
const TIMEOUT_MS = 10000;
|
||||||
const CONCURRENCY = 32;
|
const CONCURRENCY = 16;
|
||||||
|
|
||||||
function findPosition(str: string, idx: number) {
|
function findPosition(str: string, idx: number) {
|
||||||
const lines = str.substring(0, idx).split("\n");
|
const lines = str.substring(0, idx).split("\n");
|
||||||
|
@ -101,8 +101,8 @@ class Test {
|
||||||
case "ensure":
|
case "ensure":
|
||||||
await this.testEnsure();
|
await this.testEnsure();
|
||||||
break;
|
break;
|
||||||
case "hello":
|
case "run":
|
||||||
await this.testHello();
|
await this.testRun();
|
||||||
break;
|
break;
|
||||||
case "repl":
|
case "repl":
|
||||||
await this.testRepl();
|
await this.testRepl();
|
||||||
|
@ -153,14 +153,22 @@ class Test {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
waitForOutput = async (pattern: string) => {
|
waitForOutput = async (pattern: string, maxLength?: number) => {
|
||||||
let output = "";
|
let output = "";
|
||||||
return await this.wait(`output ${JSON.stringify(pattern)}`, (msg: any) => {
|
return await this.wait(`output ${JSON.stringify(pattern)}`, (msg: any) => {
|
||||||
const prevLength = output.length;
|
const prevLength = output.length;
|
||||||
if (msg.event === "terminalOutput") {
|
if (msg.event === "terminalOutput") {
|
||||||
output += msg.output;
|
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}`);
|
throw new Error(`ensure failed with code ${code}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
testHello = async () => {
|
testRun = async () => {
|
||||||
const pattern = this.config.hello || "Hello, world!";
|
const pattern = this.config.hello || "Hello, world!";
|
||||||
this.send({ event: "runCode", code: this.config.template });
|
this.send({ event: "runCode", code: this.config.template });
|
||||||
if (this.config.helloInput !== undefined) {
|
if (this.config.helloInput !== undefined) {
|
||||||
|
@ -184,7 +192,7 @@ class Test {
|
||||||
input: forTTY(this.config.helloInput),
|
input: forTTY(this.config.helloInput),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await this.waitForOutput(pattern);
|
await this.waitForOutput(pattern, this.config.helloMaxLength);
|
||||||
};
|
};
|
||||||
testRepl = async () => {
|
testRepl = async () => {
|
||||||
const input = this.config.input || "123 * 234";
|
const input = this.config.input || "123 * 234";
|
||||||
|
@ -547,7 +555,7 @@ const testTypes: {
|
||||||
ensure: {
|
ensure: {
|
||||||
pred: ({ ensure }) => (ensure ? true : false),
|
pred: ({ ensure }) => (ensure ? true : false),
|
||||||
},
|
},
|
||||||
hello: { pred: (config) => true },
|
run: { pred: (config) => true },
|
||||||
repl: {
|
repl: {
|
||||||
pred: ({ repl }) => (repl ? true : false),
|
pred: ({ repl }) => (repl ? true : false),
|
||||||
},
|
},
|
||||||
|
@ -653,8 +661,7 @@ async function main() {
|
||||||
`FAILED: ${lang}/${type}\n` +
|
`FAILED: ${lang}/${type}\n` +
|
||||||
test.getLog({ pretty: true }) +
|
test.getLog({ pretty: true }) +
|
||||||
"\n" +
|
"\n" +
|
||||||
err.stack +
|
(err.stack ? err.stack + "\n" : err ? `${err}` : "")
|
||||||
"\n"
|
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
|
@ -671,8 +678,8 @@ async function main() {
|
||||||
if (failed.size > 0) {
|
if (failed.size > 0) {
|
||||||
console.error(`${failed.size} test${failed.size !== 1 ? "s" : ""} FAILED`);
|
console.error(`${failed.size} test${failed.size !== 1 ? "s" : ""} FAILED`);
|
||||||
_.sortBy(Array.from(failed), [
|
_.sortBy(Array.from(failed), [
|
||||||
"lang",
|
([{ lang }, _]: any) => lang,
|
||||||
"type",
|
([{ type }, _]: any) => type,
|
||||||
]).forEach(([{ lang, type }, err]) =>
|
]).forEach(([{ lang, type }, err]) =>
|
||||||
console.error(` - ${lang}/${type} (${err})`)
|
console.error(` - ${lang}/${type} (${err})`)
|
||||||
);
|
);
|
||||||
|
|
|
@ -61,6 +61,6 @@
|
||||||
"dev": "run-p backend-dev frontend-dev system-dev server-dev",
|
"dev": "run-p backend-dev frontend-dev system-dev server-dev",
|
||||||
"lsp-repl": "node backend/out/lsp-repl.js",
|
"lsp-repl": "node backend/out/lsp-repl.js",
|
||||||
"sandbox": "node backend/out/sandbox.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 \"$@\"' --"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"downlevelIteration": true,
|
||||||
"outDir": "./backend/out",
|
"outDir": "./backend/out",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"rootDir": "./backend/src",
|
"rootDir": "./backend/src",
|
||||||
|
|
Loading…
Reference in New Issue