From 0b344425ebf0fab8128bb2b3cb1783849eb16bc9 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Wed, 22 Jul 2026 23:20:33 -0700 Subject: [PATCH] test(worktree): align teardown/watch tests with verified-exit behavior (#10115) - orca-runtime: 'stop cannot be proven' now requires the fresh PTY inventory to still show the pty live (empty inventory proves exit post-#10106). - git-common-watch: swap worktrees dir->file synchronously so no poll tick observes the transient ENOENT window and fabricates a delete. (cherry picked from commit e11736d7e170982eeebe09256eb549446a4f4f7b) Co-authored-by: Orca --- src/main/ipc/worktree-git-common-watch.test.ts | 8 ++++++-- src/main/runtime/orca-runtime.test.ts | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/ipc/worktree-git-common-watch.test.ts b/src/main/ipc/worktree-git-common-watch.test.ts index e4c508e45..f067e3225 100644 --- a/src/main/ipc/worktree-git-common-watch.test.ts +++ b/src/main/ipc/worktree-git-common-watch.test.ts @@ -1,5 +1,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest' import { appendFile, mkdtemp, mkdir, realpath, rm, writeFile } from 'node:fs/promises' +import { rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { subscribeViaWatcherProcess } from './parcel-watcher-process' @@ -362,8 +363,11 @@ describe('worktree git-common polling gate (non-darwin)', () => { await new Promise((resolve) => setTimeout(resolve, POLL_MS * 2)) const worktreesDir = join(commonDir, 'worktrees') - await rm(worktreesDir, { recursive: true, force: true }) - await writeFile(worktreesDir, 'not-a-dir') + // Swap dir -> file synchronously so no event-loop turn (and thus no poll + // tick) observes the transient ENOENT window, which would legitimately emit + // a delete and defeat the non-ENOENT assertion below. + rmSync(worktreesDir, { recursive: true, force: true }) + writeFileSync(worktreesDir, 'not-a-dir') await new Promise((resolve) => setTimeout(resolve, POLL_MS * 4)) expect(received.flat()).not.toContainEqual({ type: 'delete', path: entry }) diff --git a/src/main/runtime/orca-runtime.test.ts b/src/main/runtime/orca-runtime.test.ts index 0a83a6e4a..e9f6698e4 100644 --- a/src/main/runtime/orca-runtime.test.ts +++ b/src/main/runtime/orca-runtime.test.ts @@ -36951,7 +36951,11 @@ describe('OrcaRuntimeService', () => { }) it('does not start Git removal when physical PTY stop cannot be proven', async () => { - const localProvider = createProviderStub(async () => []) + // A failed stop only rejects when a fresh inventory still shows the PTY + // live; keep pty-1 present so the exit cannot be proven. + const localProvider = createProviderStub(async () => [ + { id: 'pty-1', cwd: '/tmp', title: 'shell' } + ]) const runtime = new OrcaRuntimeService(store, undefined, { getLocalProvider: () => localProvider as never })