testUpdateMakingACycle
An update that makes a cycle (the new code uses one that uses it) saves the other with it: they're hashed as one.
import { okIn, tempDir } from "#codebase/tcmts/cli/test/e2e/harness"; import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; export const testUpdateMakingACycle = () => { const dir = tempDir("cycles"); const ok = (...args: string[]) => okIn(dir, ...args); const scratch = path.join(dir, "scratch.ts"); ok("init"); fs.writeFileSync(scratch, `// tcm: namespace lib\nexport const a = (n: number): number => 0;\nexport const b = (n: number): number => a(n) + 1;\n`); ok("add"); fs.writeFileSync(scratch, `// tcm: namespace lib\nimport { b } from "#codebase/lib";\nexport const a = (n: number): number => (n <= 0 ? 0 : b(n - 1));\n`); assert.match(ok("update"), /with lib\.b: in a cycle with what changed, so saved with it[\s\S]*~ update +lib\.a[\s\S]*~ update +lib\.b/); assert.equal(ok("run", "lib.b", "2").trim(), "3"); }