From 4db2746e31404fa813c3916dca83c09e716519a8 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Tue, 19 May 2026 16:10:43 -0400 Subject: [PATCH] Reduce snapshot batch test fixture sizes (#28381) --- packages/opencode/test/snapshot/snapshot.test.ts | 11 +++++++---- perf/test-suite.md | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/opencode/test/snapshot/snapshot.test.ts b/packages/opencode/test/snapshot/snapshot.test.ts index de60d58b2d..40ce18faaf 100644 --- a/packages/opencode/test/snapshot/snapshot.test.ts +++ b/packages/opencode/test/snapshot/snapshot.test.ts @@ -15,6 +15,9 @@ const it = testEffect(Layer.mergeAll(Snapshot.defaultLayer, AppFileSystem.defaul // with path.join (which produces \ on Windows) then normalizes back to /. // This helper does the same for expected values so assertions match cross-platform. const fwd = (...parts: string[]) => path.join(...parts).replaceAll("\\", "/") +const SNAPSHOT_BATCH_BOUNDARY = 100 +const OVER_BATCH_COUNT = SNAPSHOT_BATCH_BOUNDARY + 1 +const MIXED_BATCH_GROUP_COUNT = Math.ceil(OVER_BATCH_COUNT / 4) afterEach(async () => { await disposeAllInstances() @@ -802,7 +805,7 @@ it.instance( Effect.gen(function* () { const tmp = yield* bootstrap() const snapshot = yield* Snapshot.Service - const ids = Array.from({ length: 60 }, (_, i) => i.toString().padStart(3, "0")) + const ids = Array.from({ length: MIXED_BATCH_GROUP_COUNT }, (_, i) => i.toString().padStart(3, "0")) const mod = ids.map((id) => fwd(tmp.path, "mix", `${id}-mod.txt`)) const del = ids.map((id) => fwd(tmp.path, "mix", `${id}-del.txt`)) const add = ids.map((id) => fwd(tmp.path, "mix", `${id}-add.txt`)) @@ -862,7 +865,7 @@ it.instance( Effect.gen(function* () { const tmp = yield* bootstrap() const snapshot = yield* Snapshot.Service - const ids = Array.from({ length: 140 }, (_, i) => i.toString().padStart(3, "0")) + const ids = Array.from({ length: OVER_BATCH_COUNT }, (_, i) => i.toString().padStart(3, "0")) yield* mkdirp(`${tmp.path}/order`) yield* Effect.all( ids.map((id) => write(`${tmp.path}/order/${id}.txt`, `before-${id}`)), @@ -1090,8 +1093,8 @@ it.instance( Effect.gen(function* () { const tmp = yield* bootstrap() const snapshot = yield* Snapshot.Service - const base = Array.from({ length: 140 }, (_, i) => fwd(tmp.path, "batch", `${i}.txt`)) - const fresh = Array.from({ length: 140 }, (_, i) => fwd(tmp.path, "fresh", `${i}.txt`)) + const base = Array.from({ length: OVER_BATCH_COUNT }, (_, i) => fwd(tmp.path, "batch", `${i}.txt`)) + const fresh = [fwd(tmp.path, "fresh", "0.txt")] yield* mkdirp(`${tmp.path}/batch`) yield* mkdirp(`${tmp.path}/fresh`) yield* Effect.all( diff --git a/perf/test-suite.md b/perf/test-suite.md index 77f7e7359b..1535443fe4 100644 --- a/perf/test-suite.md +++ b/perf/test-suite.md @@ -82,6 +82,7 @@ Repeated setup work, long sleeps/timeouts, serial integration tests, filesystem/ | Local plugin and subagent config fixtures can use Effect-aware instance fixtures | Migrated scoped npm plugin and custom subagent markdown cases to `it.instance` | 2.37s | 1.67s | keep | Single baseline before edit; after median from three sequential reruns (1.66, 1.67, 1.67). | | MCP merge config cases can use Effect-aware instance fixtures | Migrated three MCP merge/override cases to `it.instance` | 1.98s | 1.95s | keep | Neutral timing within noise; removes manual `tmpdir` + `withTestInstance` setup from isolated filesystem-only config cases. | | Remaining legacy tools config cases can use Effect-aware instance fixtures | Migrated allow/deny legacy `tools` permission cases to `it.instance` | 2.65s | 1.90s | keep | Single baseline before edit; after median from three sequential reruns (2.58, 1.90, 1.90). | +| Oversized snapshot batch tests only need to cross the 100-file boundary | Reduced large diff/revert fixture sizes while keeping each case above the batch boundary | 4.32s | 3.66s | keep | Three affected snapshot tests; after median from three reruns (4.32, 3.66, 3.66) while still crossing the 100-file boundary. | ## Profiling Results