Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
test(sqlite): keep incomplete cleanup primary over late cancellation (#5365)
Vishal Tambi465e1a1f3694
diff --git a/tests/boundary/sqlite/sqliteDatabaseProvider.test.ts b/tests/boundary/sqlite/sqliteDatabaseProvider.test.tsindex b56ba9ba7..62ae1a6fb 100644--- a/tests/boundary/sqlite/sqliteDatabaseProvider.test.ts+++ b/tests/boundary/sqlite/sqliteDatabaseProvider.test.ts@@ -6,6 +6,7 @@ import { promisify } from "node:util";import { fileURLToPath } from "node:url";import { expect, it as nativeTest, onTestFinished } from "vitest";import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";+import { ProviderCleanupError } from "../../../src/domain/providerCleanupError.js";import { SqliteDatabaseProvider } from "../../../src/sqlite/SqliteDatabaseProvider.js";import { inspectSqliteDatabaseSnapshot } from "../../../src/sqlite/SqliteDatabaseInspection.js";import { cleanupOwnedProcessGroup } from "../../../src/process/ProcessOwnership.js";@@ -380,7 +381,7 @@ nativeTest(},);-it.each(["late-cancellation", "cleanup-failure"])(+it.each(["late-cancellation", "cleanup-failure", "cancelled cleanup-failure"])("preserves completed native-worker observations across %s",async (scenario) => {const { workspace, database } = await createFixture();@@ -406,9 +407,9 @@ it.each(["late-cancellation", "cleanup-failure"])(return {path: acquired.path,close: async () => {- if (scenario === "late-cancellation")+ if (scenario !== "cleanup-failure")controller.abort(cancellationReason);- else if (!cleanupAllowed)+ if (scenario !== "late-cancellation" && !cleanupAllowed)throw new Error("Completed snapshot cleanup denied");await acquired.close();},@@ -460,7 +461,16 @@ it.each(["late-cancellation", "cleanup-failure"])(if (result.ok || result.error._tag !== "AnalysisCancelledError")throw new Error("Expected cancellation after final root cleanup");expect(result.error.cause).toBe(cancellationReason);+ if (root === undefined) throw new Error("Missing acquired root");+ await expectPrivateRootRemoved(root.path);} else {+ // Incomplete cleanup stays primary over a cancellation observed during it.+ expect(controller.signal.aborted).toBe(+ scenario === "cancelled cleanup-failure",+ );+ expect(result.ok ? undefined : result.error).toBeInstanceOf(+ ProviderCleanupError,+ );expect(result).toMatchObject({ok: false,error: {