Эх сурвалжийг харах

fix: bound Windows integration test cleanup and I/O waits

hetaoBackend 2 сар өмнө
parent
commit
2cd00d7aa2

+ 3 - 1
packages/local-runtime-v2/test/unit/agent/storage/agent.repository.test.ts

@@ -169,6 +169,8 @@ async function seed(repository: DrizzleAgentRepository): Promise<void> {
 }
 
 describe("Frozen Session deletion continuity", () => {
+  // This real-database create/delete/recreate sequence exceeded 5s on Windows CI.
+  // Keep the larger I/O budget local to this integration case.
   it("reads the persisted definition and renders after deleting and recreating its Agent", async () => {
     const { repository, database, dataDir } = await createRepository();
     const agentService = createTestAgentService({
@@ -275,7 +277,7 @@ describe("Frozen Session deletion continuity", () => {
     const afterRecreate = await read();
     expect(afterRecreate).toEqual(afterDelete);
     expect(afterRecreate.corePrompt).not.toContain("NEW_AGENT_PROMPT");
-  });
+  }, process.platform === "win32" ? 15_000 : 5_000);
 });
 
 describe("Local Agent reference resolver integration", () => {

+ 3 - 1
packages/local-runtime/test/unit/child-bash-lifecycle.test.ts

@@ -36,6 +36,8 @@ function nodeCommand(script: string): string {
 
 const directories: string[] = [];
 const shutdowns: Array<() => Promise<void>> = [];
+// Windows CI has exceeded the 10s teardown budget for these SQLite/output fixtures.
+// Keep the execution deadlines below separate from this bounded teardown budget.
 afterEach(async () => {
   // A terminal task can still be finalizing output or scheduling delivery.
   // Drain that work before closing SQLite, otherwise it can reopen the file
@@ -45,7 +47,7 @@ afterEach(async () => {
     closeLocalRuntimeDb(path);
     await rm(path, { recursive: true, force: true });
   }
-});
+}, process.platform === 'win32' ? 30_000 : 10_000);
 async function fixture() {
   const dataDir = await mkdtemp(join(tmpdir(), 'child-bash-lifecycle-'));
   directories.push(dataDir);

+ 16 - 3
packages/local-runtime/test/unit/session-diff-fallback.test.ts

@@ -13,6 +13,7 @@ let root: string;
 let workspaceDir: string;
 let dataDir: string;
 let diffStore: SqliteLocalTurnDiffStore;
+const pendingReads = new Set<ReturnType<typeof readLocalSessionDiff>>();
 
 function git(...args: string[]): string {
   return execFileSync('git', args, { cwd: workspaceDir, encoding: 'utf8' });
@@ -29,11 +30,17 @@ function commit(): void {
 }
 
 async function read(messageId?: string) {
-  return readLocalSessionDiff({
+  const pending = readLocalSessionDiff({
     diffStore,
     session: { sessionId: 'test-session', workspaceDir },
     messageId,
   });
+  pendingReads.add(pending);
+  try {
+    return await pending;
+  } finally {
+    pendingReads.delete(pending);
+  }
 }
 
 beforeEach(async () => {
@@ -58,10 +65,14 @@ beforeEach(async () => {
 });
 
 afterEach(async () => {
+  // A Vitest timeout does not cancel the Git processes started by a read.
+  // Drain them before changing their environment or deleting their cwd; otherwise
+  // Windows reports EBUSY and unfinished work can overlap the next fixture.
+  await Promise.allSettled(pendingReads);
   closeLocalRuntimeDb(dataDir);
   vi.unstubAllEnvs();
   await rm(root, { recursive: true, force: true });
-});
+}, process.platform === 'win32' ? 30_000 : 10_000);
 
 const portableNames = ['中文.txt', 'with spaces.txt', 'dir/{before after}.txt'];
 const posixNames = [
@@ -77,6 +88,8 @@ describe.each(['true', 'false'])('session diff fallback with core.quotePath=%s',
     git('config', 'core.quotePath', quotePath);
   });
 
+  // This integration case creates a commit, migrates SQLite and runs real Git.
+  // Real Windows runs have exhausted its default 5s test deadline.
   it('preserves Unicode paths and attaches each tracked patch through the public API', async () => {
     for (const file of portableNames) await write(file, 'first\n');
     commit();
@@ -94,7 +107,7 @@ describe.each(['true', 'false'])('session diff fallback with core.quotePath=%s',
         diff: expect.stringContaining(`+added-${index}\n`),
       });
     }
-  });
+  }, process.platform === 'win32' ? 15_000 : 5_000);
 
   it('reports rename edits against the destination path', async () => {
     await write('before.txt', 'a\nb\nc\nd\ne\nf\n');