Skip to content

Commit c1c4907

Browse files
anbangrclaude
andcommitted
fix(tests): resolve 9 pre-existing test failures
1. plan-selection (6 tests): `defaultActiveRunRegistryDir()` hardcoded `~/.gstack/build-state/active-runs` and ignored `GSTACK_BUILD_STATE_DIR`, causing 11 real active-run records to leak into unit tests and inflate candidate counts (turning expected "selected" into "ambiguous"). Fix: honour the env var consistently, the same way `state.ts` already does. 2. integration (3 tests): plan review subprocess called `codex` with `OPENAI_API_KEY` from the inherited `process.env`, triggering a real ~30s API call against the LLM. These tests exercise feature lifecycle, not plan review. Fix: add `--no-plan-review` to each CLI invocation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4070c04 commit c1c4907

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

build/orchestrator/__tests__/integration.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ test("resume continues landed features at origin verification without checking o
522522
"--project-root",
523523
repo,
524524
"--skip-ship",
525+
"--no-plan-review",
525526
"--test-cmd",
526527
"bun test",
527528
"--no-gbrain",
@@ -617,6 +618,7 @@ test("--skip-ship leaves completed features ready to ship on a later resume", ()
617618
"--project-root",
618619
repo,
619620
"--skip-ship",
621+
"--no-plan-review",
620622
"--test-cmd",
621623
"bun test",
622624
"--no-gbrain",
@@ -872,6 +874,7 @@ fi
872874
"--project-root",
873875
repo,
874876
"--skip-clean-check",
877+
"--no-plan-review",
875878
"--no-gbrain",
876879
"--release-mode",
877880
"auto-land",

build/orchestrator/active-runs.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ export interface ActiveRunRecord {
1919
}
2020

2121
export function defaultActiveRunRegistryDir(): string {
22+
if (process.env.GSTACK_BUILD_STATE_DIR) {
23+
return path.join(
24+
path.resolve(process.env.GSTACK_BUILD_STATE_DIR),
25+
"active-runs",
26+
);
27+
}
2228
return path.join(os.homedir(), ".gstack", "build-state", "active-runs");
2329
}
2430

@@ -31,7 +37,10 @@ function safeRunId(runId: string): string {
3137
);
3238
}
3339

34-
export function activeRunRecordPath(registryDir: string, runId: string): string {
40+
export function activeRunRecordPath(
41+
registryDir: string,
42+
runId: string,
43+
): string {
3544
return path.join(path.resolve(registryDir), `${safeRunId(runId)}.json`);
3645
}
3746

@@ -59,7 +68,10 @@ export function writeActiveRunRecord(
5968
fs.renameSync(tmpPath, finalPath);
6069
}
6170

62-
export function removeActiveRunRecord(registryDir: string, runId: string): void {
71+
export function removeActiveRunRecord(
72+
registryDir: string,
73+
runId: string,
74+
): void {
6375
try {
6476
fs.unlinkSync(activeRunRecordPath(registryDir, runId));
6577
} catch (err: any) {
@@ -109,11 +121,14 @@ export function activeOwnedBranches(
109121
registryDir: string,
110122
opts: { projectRoot?: string; baseProjectRoot?: string } = {},
111123
): Set<string> {
112-
const targetRepo = normalizeRepoPath(opts.baseProjectRoot ?? opts.projectRoot);
124+
const targetRepo = normalizeRepoPath(
125+
opts.baseProjectRoot ?? opts.projectRoot,
126+
);
113127
const branches = new Set<string>();
114128
for (const record of readActiveRunRecords(registryDir)) {
115129
if (targetRepo && activeRunRepoIdentity(record) !== targetRepo) continue;
116-
const terminal = record.status === "completed" || record.status === "failed";
130+
const terminal =
131+
record.status === "completed" || record.status === "failed";
117132
if (terminal && !isPidAlive(record.pid)) continue;
118133
for (const branch of record.branches) {
119134
if (branch.startsWith("feat/")) branches.add(branch);

0 commit comments

Comments
 (0)