From 8ee362233e21b1fd32a459075113ebfaca2f13c6 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 5 May 2026 20:18:36 -0700 Subject: [PATCH] Stabilize git workspace and terminal tests - Add a helper for visible remote URLs with local path rewrites - Speed up the pre-commit hook in the git manager tests - Default terminal kill grace to 1ms in the test harness --- apps/server/src/git/GitManager.test.ts | 99 +++++++++++-------- .../src/terminal/Layers/Manager.test.ts | 4 +- 2 files changed, 61 insertions(+), 42 deletions(-) diff --git a/apps/server/src/git/GitManager.test.ts b/apps/server/src/git/GitManager.test.ts index b5c9c0338fd..4dba7f9842b 100644 --- a/apps/server/src/git/GitManager.test.ts +++ b/apps/server/src/git/GitManager.test.ts @@ -294,6 +294,18 @@ function configureRemote( }); } +function configureVisibleRemoteUrlWithLocalRewrite( + cwd: string, + remoteName: string, + visibleUrl: string, + localRemotePath: string, +): Effect.Effect { + return Effect.gen(function* () { + yield* runGit(cwd, ["config", `remote.${remoteName}.url`, visibleUrl]); + yield* runGit(cwd, ["config", `url.${localRemotePath}.insteadOf`, visibleUrl]); + }); +} + function createTextGeneration(overrides: Partial = {}): TextGenerationShape { const implementation: FakeGitTextGeneration = { generateCommitMessage: (input) => @@ -1012,11 +1024,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => { yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-488/statemachine"]); yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]); - yield* runGit(repoDir, [ - "config", - "remote.fork-seed.url", + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "fork-seed", "git@github.com:jasonLaster/codething-mvp.git", - ]); + forkDir, + ); const { manager, ghCalls } = yield* makeManager({ ghScenario: { @@ -1076,17 +1089,19 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => { yield* runGit(repoDir, ["checkout", "-b", "effect-atom"]); yield* runGit(repoDir, ["push", "-u", "origin", "effect-atom"]); yield* runGit(repoDir, ["push", "-u", "my-org/upstream", "effect-atom"]); - yield* runGit(repoDir, [ - "config", - "remote.origin.url", + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "origin", "git@github.com:pingdotgg/codething-mvp.git", - ]); + originDir, + ); yield* runGit(repoDir, ["config", "remote.origin.pushurl", originDir]); - yield* runGit(repoDir, [ - "config", - "remote.my-org/upstream.url", - "git@github.com:pingdotgg/codething-mvp.git", - ]); + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "my-org/upstream", + "ssh://git@github.com/pingdotgg/codething-mvp.git", + upstreamDir, + ); yield* runGit(repoDir, ["config", "remote.my-org/upstream.pushurl", upstreamDir]); yield* runGit(repoDir, ["checkout", "main"]); yield* runGit(repoDir, ["branch", "-D", "effect-atom"]); @@ -1861,11 +1876,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => { const forkDir = yield* createBareRemote(); yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]); yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); - yield* runGit(repoDir, [ - "config", - "remote.fork-seed.url", + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "fork-seed", "git@github.com:octocat/codething-mvp.git", - ]); + forkDir, + ); const { manager, ghCalls } = yield* makeManager({ ghScenario: { @@ -1923,17 +1939,19 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => { yield* runGit(repoDir, ["checkout", "-b", "effect-atom"]); yield* runGit(repoDir, ["push", "-u", "origin", "effect-atom"]); yield* runGit(repoDir, ["push", "-u", "my-org/upstream", "effect-atom"]); - yield* runGit(repoDir, [ - "config", - "remote.origin.url", + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "origin", "git@github.com:pingdotgg/codething-mvp.git", - ]); + originDir, + ); yield* runGit(repoDir, ["config", "remote.origin.pushurl", originDir]); - yield* runGit(repoDir, [ - "config", - "remote.my-org/upstream.url", - "git@github.com:pingdotgg/codething-mvp.git", - ]); + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "my-org/upstream", + "ssh://git@github.com/pingdotgg/codething-mvp.git", + upstreamDir, + ); yield* runGit(repoDir, ["config", "remote.my-org/upstream.pushurl", upstreamDir]); yield* runGit(repoDir, ["checkout", "main"]); yield* runGit(repoDir, ["branch", "-D", "effect-atom"]); @@ -2013,11 +2031,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => { yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]); yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]); - yield* runGit(repoDir, [ - "config", - "remote.fork-seed.url", + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "fork-seed", "git@github.com:octocat/codething-mvp.git", - ]); + forkDir, + ); const { manager, ghCalls } = yield* makeManager({ ghScenario: { @@ -2083,11 +2102,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => { yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]); yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]); - yield* runGit(repoDir, [ - "config", - "remote.fork-seed.url", + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "fork-seed", "git@github.com:octocat/codething-mvp.git", - ]); + forkDir, + ); const { manager, ghCalls } = yield* makeManager({ ghScenario: { @@ -2263,11 +2283,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => { yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-91/statemachine"]); yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]); - yield* runGit(repoDir, [ - "config", - "remote.fork-seed.url", + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "fork-seed", "git@github.com:octocat/codething-mvp.git", - ]); + forkDir, + ); const { manager, ghCalls } = yield* makeManager({ ghScenario: { @@ -3147,7 +3168,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => { fs.writeFileSync(path.join(repoDir, "hooked.txt"), "hooked\n"); fs.writeFileSync( path.join(repoDir, ".git", "hooks", "pre-commit"), - '#!/bin/sh\necho "hook: start" >&2\nsleep 1\necho "hook: end" >&2\n', + '#!/bin/sh\necho "hook: start" >&2\nsleep 0.05\necho "hook: end" >&2\n', { mode: 0o755 }, ); diff --git a/apps/server/src/terminal/Layers/Manager.test.ts b/apps/server/src/terminal/Layers/Manager.test.ts index 9d41c3de20f..7c4f429e40d 100644 --- a/apps/server/src/terminal/Layers/Manager.test.ts +++ b/apps/server/src/terminal/Layers/Manager.test.ts @@ -238,9 +238,7 @@ const createManager = ( ...(options.subprocessPollIntervalMs !== undefined ? { subprocessPollIntervalMs: options.subprocessPollIntervalMs } : {}), - ...(options.processKillGraceMs !== undefined - ? { processKillGraceMs: options.processKillGraceMs } - : {}), + processKillGraceMs: options.processKillGraceMs ?? 1, ...(options.maxRetainedInactiveSessions !== undefined ? { maxRetainedInactiveSessions: options.maxRetainedInactiveSessions } : {}),