testResultsTravelThroughAServer
Tests' results and lint findings travel through a server too: pushed with the code, and pulled from it by a codebase that hasn't run or linted it.
import { tempDir, withChildren } from "#codebase/tcmts/cli/test/e2e/harness"; import { codebase, startServer } from "#codebase/tcmts/cli/test/e2e/sync"; import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; export const testResultsTravelThroughAServer = () => withChildren(async (keep) => { const root = tempDir("sync results server"); const server = codebase(root, "server"); fs.rmSync(path.join(server.dir, "scratch.ts")); const url = await startServer(keep, server.dir, "tok"); const a = codebase(root, "a"); a.scratch( `// tcm: namespace lib\nexport const square = (x: number) => x * x;\nexport const testSquare = () => { if (square(3) !== 9) throw new Error("no"); };\n`, ); a.tcm("add"); assert.match(a.tcm("test"), /1 passed, 0 failed\n/); assert.match(a.tcm("lint", "lib"), /in 2 definition\(s\)/); a.tcm("remote", "add", "origin", url, "--token", "tok"); assert.match(a.tcm("push"), /, 1 test result\(s\), 2 lint result\(s\)/); const b = codebase(root, "b"); fs.rmSync(path.join(b.dir, "scratch.ts")); b.tcm("remote", "add", "origin", url, "--token", "tok"); const pulled = b.tcm("pull"); assert.match(pulled, /received 1 test result\(s\)/); assert.match(pulled, /received 2 lint result\(s\)/); assert.match(b.tcm("test"), /1 passed, 0 failed \(1 cached\)/); assert.match( b.tcm("lint", "lib"), /in 2 definition\(s\) \(2 cached\)/, "linted there, not again here", ); })