diff --git a/backend/src/api.ts b/backend/src/api.ts index a0ba51b..e63c8a5 100644 --- a/backend/src/api.ts +++ b/backend/src/api.ts @@ -4,6 +4,7 @@ import * as WebSocket from "ws"; import * as pty from "node-pty"; import { IPty } from "node-pty"; +import PQueue from "p-queue"; import * as rpc from "vscode-jsonrpc"; import { v4 as getUUID } from "uuid"; @@ -44,6 +45,8 @@ export class Session { logPrimitive: (msg: string) => void; + msgQueue: PQueue = new PQueue({ concurrency: 1 }); + get homedir() { return `/tmp/riju/${this.uuid}`; } @@ -158,7 +161,9 @@ export class Session { ); this.send({ event: "lspStarted", root: this.homedir }); } - this.ws.on("message", this.receive); + this.ws.on("message", (msg: string) => + this.msgQueue.add(() => this.receive(msg)) + ); this.ws.on("close", async () => { await this.teardown(); }); diff --git a/backend/src/langs.ts b/backend/src/langs.ts index 1d8b58c..2ad5df1 100644 --- a/backend/src/langs.ts +++ b/backend/src/langs.ts @@ -1388,8 +1388,14 @@ main = do }, }, }, - template: `print('Hello, world!') + template: `print("Hello, world!") `, + test: { + format: { + input: `print('Hello, world!') +`, + }, + }, }, قلب: { aliases: ["qalb"], diff --git a/backend/src/test-runner.ts b/backend/src/test-runner.ts index 9c23c99..7d5ba9c 100644 --- a/backend/src/test-runner.ts +++ b/backend/src/test-runner.ts @@ -86,6 +86,9 @@ class Test { case "repl": await this.testRepl(); break; + case "runrepl": + await this.testRunRepl(); + break; case "scope": await this.testScope(); break; @@ -265,18 +268,48 @@ async function main() { [lang, test].concat(langs[lang].aliases || []).includes(arg) ); } + if (tests.length === 0) { + console.error("no tests selected"); + process.exit(1); + } + const lintSeen = new Set(); + let lintPassed = 0; + let lintFailed = 0; + for (const { lang } of tests) { + if (!lintSeen.has(lang)) { + lintSeen.add(lang); + console.error(`===== LANGUAGE ${lang}, LINT`); + try { + lint(lang); + console.error("passed"); + lintPassed += 1; + } catch (err) { + console.error("failed"); + console.error(err); + lintFailed += 1; + } + } + } + if (lintFailed) { + process.exit(1); + } + let passed = 0; + let failed = 0; for (const { lang, test: type } of tests) { console.error(`===== LANGUAGE ${lang}, TEST ${type}`); const test = new Test(lang, type); try { await test.run(); - console.error("succeeded"); + console.error("passed"); + passed += 1; } catch (err) { - console.error("failed:"); + console.error("failed"); console.error(test.getLog()); console.error(err); + failed += 1; } } + process.exit(failed ? 1 : 0); } main().catch(console.error); diff --git a/package.json b/package.json index d8f00c3..3dd9f95 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "monaco-languageclient": "^0.13.0", "node-pty": "^0.9.0", "npm-run-all": "^4.1.5", + "p-queue": "^6.6.0", "parse-passwd": "^1.0.0", "shell-quote": "^1.7.2", "style-loader": "^1.2.1", diff --git a/yarn.lock b/yarn.lock index de64bc2..30f466d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2118,6 +2118,11 @@ etag@~1.8.1: resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= +eventemitter3@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.4.tgz#b5463ace635a083d018bdc7c917b4c5f10a85384" + integrity sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ== + events@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/events/-/events-3.1.0.tgz#84279af1b34cb75aa88bf5ff291f6d0bd9b31a59" @@ -3659,6 +3664,21 @@ p-locate@^3.0.0: dependencies: p-limit "^2.0.0" +p-queue@^6.6.0: + version "6.6.0" + resolved "https://registry.yarnpkg.com/p-queue/-/p-queue-6.6.0.tgz#263f2b73add4cefca81d8d6b2696ee74b326de2f" + integrity sha512-zPHXPNy9jZsiym0PpJjvnHQysx1fSd/QdaNVwiDRLU2KFChD6h9CkCB6b8i3U8lBwJyA+mHgNZCzcy77glUssQ== + dependencies: + eventemitter3 "^4.0.4" + p-timeout "^3.1.0" + +p-timeout@^3.1.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-3.2.0.tgz#c7e17abc971d2a7962ef83626b35d635acf23dfe" + integrity sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg== + dependencies: + p-finally "^1.0.0" + p-try@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"