Skip to content

Commit 4db2746

Browse files
authored
Reduce snapshot batch test fixture sizes (#28381)
1 parent 71e9007 commit 4db2746

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/opencode/test/snapshot/snapshot.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const it = testEffect(Layer.mergeAll(Snapshot.defaultLayer, AppFileSystem.defaul
1515
// with path.join (which produces \ on Windows) then normalizes back to /.
1616
// This helper does the same for expected values so assertions match cross-platform.
1717
const fwd = (...parts: string[]) => path.join(...parts).replaceAll("\\", "/")
18+
const SNAPSHOT_BATCH_BOUNDARY = 100
19+
const OVER_BATCH_COUNT = SNAPSHOT_BATCH_BOUNDARY + 1
20+
const MIXED_BATCH_GROUP_COUNT = Math.ceil(OVER_BATCH_COUNT / 4)
1821

1922
afterEach(async () => {
2023
await disposeAllInstances()
@@ -802,7 +805,7 @@ it.instance(
802805
Effect.gen(function* () {
803806
const tmp = yield* bootstrap()
804807
const snapshot = yield* Snapshot.Service
805-
const ids = Array.from({ length: 60 }, (_, i) => i.toString().padStart(3, "0"))
808+
const ids = Array.from({ length: MIXED_BATCH_GROUP_COUNT }, (_, i) => i.toString().padStart(3, "0"))
806809
const mod = ids.map((id) => fwd(tmp.path, "mix", `${id}-mod.txt`))
807810
const del = ids.map((id) => fwd(tmp.path, "mix", `${id}-del.txt`))
808811
const add = ids.map((id) => fwd(tmp.path, "mix", `${id}-add.txt`))
@@ -862,7 +865,7 @@ it.instance(
862865
Effect.gen(function* () {
863866
const tmp = yield* bootstrap()
864867
const snapshot = yield* Snapshot.Service
865-
const ids = Array.from({ length: 140 }, (_, i) => i.toString().padStart(3, "0"))
868+
const ids = Array.from({ length: OVER_BATCH_COUNT }, (_, i) => i.toString().padStart(3, "0"))
866869
yield* mkdirp(`${tmp.path}/order`)
867870
yield* Effect.all(
868871
ids.map((id) => write(`${tmp.path}/order/${id}.txt`, `before-${id}`)),
@@ -1090,8 +1093,8 @@ it.instance(
10901093
Effect.gen(function* () {
10911094
const tmp = yield* bootstrap()
10921095
const snapshot = yield* Snapshot.Service
1093-
const base = Array.from({ length: 140 }, (_, i) => fwd(tmp.path, "batch", `${i}.txt`))
1094-
const fresh = Array.from({ length: 140 }, (_, i) => fwd(tmp.path, "fresh", `${i}.txt`))
1096+
const base = Array.from({ length: OVER_BATCH_COUNT }, (_, i) => fwd(tmp.path, "batch", `${i}.txt`))
1097+
const fresh = [fwd(tmp.path, "fresh", "0.txt")]
10951098
yield* mkdirp(`${tmp.path}/batch`)
10961099
yield* mkdirp(`${tmp.path}/fresh`)
10971100
yield* Effect.all(

perf/test-suite.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Repeated setup work, long sleeps/timeouts, serial integration tests, filesystem/
8282
| 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). |
8383
| 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. |
8484
| 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). |
85+
| 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. |
8586

8687
## Profiling Results
8788

0 commit comments

Comments
 (0)