diff --git a/test/heartbeat.test.ts b/test/heartbeat.test.ts index 49fc553..912b9d7 100644 --- a/test/heartbeat.test.ts +++ b/test/heartbeat.test.ts @@ -135,12 +135,14 @@ test("after a pause of its own, the client asks before it gives up, and keeps a const ws = new WebSocket(url); await new Promise((r) => ws.on("open", r)); let why = ""; - keepAlive(ws, 40, (w) => (why = w)); - await new Promise((r) => setTimeout(r, 50)); + // Rounds of 100 ms, not 40: the check after a pause waits one round for the answer, and on Windows CI the in-process server's + // answer came later than 40 ms after the hold (2026-11-29). + keepAlive(ws, 100, (w) => (why = w)); + await new Promise((r) => setTimeout(r, 120)); // This process held up for several rounds, the way a stall or App Nap holds it: the link itself is fine. - hold(150); + hold(350); - await new Promise((r) => setTimeout(r, 300)); + await new Promise((r) => setTimeout(r, 700)); assert.equal(ws.readyState, WebSocket.OPEN, "the pause was this process's, and the server still answers"); assert.equal(why, ""); ws.terminate(); @@ -153,15 +155,15 @@ test("after a pause, a link that doesn't answer is ended at once, and says why", const ws = new WebSocket(url); await new Promise((r) => ws.on("open", r)); let why = ""; - keepAlive(ws, 40, (w) => (why = w)); - await new Promise((r) => setTimeout(r, 50)); + keepAlive(ws, 100, (w) => (why = w)); + await new Promise((r) => setTimeout(r, 120)); // What a computer waking from sleep finds: nothing answers on the other end any more. for (const c of wss.clients) c.pong = () => {}; - hold(150); + hold(350); const closed = await new Promise((r) => { ws.on("close", () => r(true)); - setTimeout(() => r(false), 300); + setTimeout(() => r(false), 700); }); assert.equal(closed, true, "so the reconnect starts now, not a minute later"); assert.match(why, /paused/); diff --git a/test/ide-git.test.ts b/test/ide-git.test.ts index a968afc..62c8089 100644 --- a/test/ide-git.test.ts +++ b/test/ide-git.test.ts @@ -10,7 +10,9 @@ import { IDE_GIT, parseStatus } from "../src/runner/ide-git.js"; const base = realpathSync(mkdtempSync(join(tmpdir(), "ide-git-"))); const home = join(base, "home"); mkdirSync(home); -writeFileSync(join(base, "gitconfig"), ""); +// Settings every repo here shares live in this run's own global file, written once: each `git config` in a new repo is a write +// Windows CI sometimes finds locked a moment after `git init` (2026-11-29). +writeFileSync(join(base, "gitconfig"), "[commit]\n\tgpgsign = false\n[user]\n\tuseConfigOnly = true\n"); process.env.HOME = home; process.env.USERPROFILE = home; // FRIDAY_HOME wins over HOME for where the trash is (ide.ts), and it is set wherever this runs from inside Friday: left as it @@ -22,6 +24,18 @@ process.env.GIT_CONFIG_NOSYSTEM = "1"; after(() => rmSync(base, { recursive: true, force: true })); const g = (cwd: string, ...args: string[]) => execFileSync("git", args, { cwd, encoding: "utf8" }).trim(); +/** A repo's own setting, tried again a few times: see the global file above. */ +function setting(cwd: string, key: string, value: string): void { + for (let i = 0; ; i++) { + try { + g(cwd, "config", key, value); + return; + } catch (e) { + if (i >= 5) throw e; + execFileSync(process.execPath, ["-e", "setTimeout(() => {}, 100)"]); + } + } +} const H = IDE_GIT as Required; let n = 0; @@ -30,11 +44,9 @@ function repo(opts: { identity?: boolean } = {}): string { mkdirSync(dir); g(dir, "init", "-q", "-b", "main"); if (opts.identity !== false) { - g(dir, "config", "user.name", "Test User"); - g(dir, "config", "user.email", "test@example.com"); + setting(dir, "user.name", "Test User"); + setting(dir, "user.email", "test@example.com"); } - g(dir, "config", "commit.gpgsign", "false"); - g(dir, "config", "user.useConfigOnly", "true"); return dir; } const put = (dir: string, rel: string, text: string) => { @@ -297,9 +309,8 @@ test("sync: push sets the upstream, fetch and pull follow it, remote branches li const b = join(base, `clone${n++}`); g(base, "clone", "-q", remote, b); - g(b, "config", "user.name", "B"); - g(b, "config", "user.email", "b@example.com"); - g(b, "config", "commit.gpgsign", "false"); + setting(b, "user.name", "B"); + setting(b, "user.email", "b@example.com"); put(b, "from-b.txt", "b"); g(b, "add", "-A"); g(b, "commit", "-q", "-m", "from b");