diff --git a/backend/src/langs.ts b/backend/src/langs.ts index 488171b..69c7283 100644 --- a/backend/src/langs.ts +++ b/backend/src/langs.ts @@ -1629,6 +1629,21 @@ PLEASE GIVE UP "curl -sS 'https://registry.npmjs.org/-/v1/search?text=NAME' | jq -r '.objects | map(.package.name) | .[]'", }, template: `console.log("Hello, world!"); +`, + }, + jq: { + name: "jq", + repl: "echo 'Reading from stdin...' >&2 && while true; do jq .; done", + input: `{"foo":"bar"}`, + output: `"foo": "bar"`, + main: "main.jq", + run: `echo 'Reading from stdin...' >&2 && while true; do jq "$(< main.jq)"; done`, + helloInput: `{}`, + // This test doesn't actually test anything, because "Hello, + // world" is already printed before anything is sent to the repl, + // but we can't do any better. + runReplOutput: `"Hello, world!"`, + template: `"Hello, world!" `, }, julia: { diff --git a/backend/src/test-runner.ts b/backend/src/test-runner.ts index 9de15c5..4cfb26c 100644 --- a/backend/src/test-runner.ts +++ b/backend/src/test-runner.ts @@ -7,6 +7,7 @@ import { Moment } from "moment"; import * as moment from "moment"; import PQueue from "p-queue"; import * as rimraf from "rimraf"; +import stripAnsi = require("strip-ansi"); import { v4 as getUUID } from "uuid"; import * as api from "./api"; @@ -187,7 +188,9 @@ class Test { return await this.wait(`output ${JSON.stringify(pattern)}`, (msg: any) => { const prevLength = output.length; if (msg.event === "terminalOutput") { - output += msg.output; + // Applying stripAnsi here is wrong because escape sequences + // could be split across multiple messages. Who cares? + output += stripAnsi(msg.output); } if (typeof maxLength === "number") { return ( diff --git a/package.json b/package.json index c58174e..e19f307 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "parse-passwd": "^1.0.0", "rimraf": "^3.0.2", "shell-quote": "^1.7.2", + "strip-ansi": "^6.0.0", "style-loader": "^1.2.1", "ts-loader": "^7.0.5", "typescript": "^3.9.5", diff --git a/scripts/docker-install-phase3b.bash b/scripts/docker-install-phase3b.bash index 72c57d7..9e46d98 100755 --- a/scripts/docker-install-phase3b.bash +++ b/scripts/docker-install-phase3b.bash @@ -64,6 +64,9 @@ intercal clang-format default-jdk +# jq +jq + # Julia julia diff --git a/yarn.lock b/yarn.lock index 27ba20a..6e944d5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1152,6 +1152,11 @@ ansi-regex@^4.1.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== +ansi-regex@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" + integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== + ansi-styles@^3.2.0, ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -4570,6 +4575,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" +strip-ansi@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" + integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== + dependencies: + ansi-regex "^5.0.0" + strip-bom@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"