testWorkInASlotTakesNoMore
Work inside a slot takes no more for what it runs: nested work runs at once (so it never waits behind itself), and what it starts as a process is told it's in the slot.
import { slotPool, withSlot } from "#codebase/tcmts/cli/budget"; import { settlesWithin } from "#codebase/tcmts/cli/budget/test"; import assert from "node:assert/strict"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; export const testWorkInASlotTakesNoMore = async () => { const dir = fs.mkdtempSync(path.join(os.tmpdir(), "tcm slots ")); try { const pool = slotPool(dir, 1); const inner = await withSlot( "verify of /x/codebase", async (env) => { assert.deepEqual(env, { TCM_SUITE_SLOT: "1" }); const nested = withSlot("app build of /x/codebase", async () => "built", { pool, say: () => {}, }); assert.equal(await settlesWithin(nested, 400), true, "not waiting behind itself"); return nested; }, { pool, say: () => {} }, ); assert.equal(inner, "built"); assert.deepEqual(fs.readdirSync(dir), []); } finally { fs.rmSync(dir, { recursive: true, force: true }); } }