Repository navigation
test(snapshot): diagnose canonical worktree timeout phases #308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,51 +98,91 @@ describe("Snapshot", () => { | |
| ), | ||
| ) | ||
|
|
||
| testEffect(Layer.empty).live("isolates snapshot indexes by canonical Git worktree", () => | ||
| Effect.acquireUseRelease( | ||
| Effect.promise(() => tmpdir()), | ||
| testEffect(Layer.empty).live("isolates snapshot indexes by canonical Git worktree", () => { | ||
| // Keep the default budget: the last start/done pair identifies the Windows | ||
| // timeout boundary, including native Git setup and scoped layer disposal. | ||
| const startedAt = Date.now() | ||
| const phase = (name: string) => | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: Inconsistent The first test (line 20-21) defines This works but creates inconsistency. Consider adding a comment explaining why this test uses a plain function (to support direct calls in Reply with |
||
| console.error(`[snapshot-worktree-test] phase=${name} elapsedMs=${Date.now() - startedAt}`) | ||
| return Effect.acquireUseRelease( | ||
| Effect.promise(async () => { | ||
| phase("tmpdir:start") | ||
| const tmp = await tmpdir() | ||
| phase("tmpdir:done") | ||
| return tmp | ||
| }), | ||
| (tmp) => | ||
| Effect.gen(function* () { | ||
| const project = path.join(tmp.path, "project") | ||
| const linked = path.join(tmp.path, "linked") | ||
| yield* Effect.promise(async () => { | ||
| phase("files:start") | ||
| await fs.mkdir(project) | ||
| await fs.writeFile(path.join(project, "tracked.txt"), "main\n") | ||
| phase("files:done") | ||
| phase("git-init:start") | ||
| await $`git init`.cwd(project).quiet() | ||
| phase("git-init:done") | ||
| phase("git-config:start") | ||
| await $`git config core.fsmonitor false`.cwd(project).quiet() | ||
| await $`git config commit.gpgsign false`.cwd(project).quiet() | ||
| await $`git config user.email [email protected]`.cwd(project).quiet() | ||
| await $`git config user.name Test`.cwd(project).quiet() | ||
| phase("git-config:done") | ||
| phase("git-add:start") | ||
| await $`git add .`.cwd(project).quiet() | ||
| phase("git-add:done") | ||
| phase("git-commit:start") | ||
| await $`git commit -m initial`.cwd(project).quiet() | ||
| phase("git-commit:done") | ||
| phase("git-worktree:start") | ||
| await $`git worktree add --detach ${linked} HEAD`.cwd(project).quiet() | ||
| phase("git-worktree:done") | ||
| }) | ||
|
|
||
| const capture = (directory: string) => | ||
| const capture = (directory: string, name: string) => | ||
| Effect.gen(function* () { | ||
| const snapshot = yield* Snapshot.Service | ||
| return yield* snapshot.capture() | ||
| }).pipe(Effect.provide(snapshotLayer(tmp.path, directory))) | ||
| expect(yield* capture(project)).toBeDefined() | ||
| expect(yield* capture(linked)).toBeDefined() | ||
| yield* Effect.sync(() => phase(`${name}-layer:start`)) | ||
| const result = yield* Effect.gen(function* () { | ||
| const snapshot = yield* Snapshot.Service | ||
| yield* Effect.sync(() => phase(`${name}-capture:start`)) | ||
| const captured = yield* snapshot.capture() | ||
| yield* Effect.sync(() => phase(`${name}-capture:done`)) | ||
| return captured | ||
| }).pipe(Effect.provide(snapshotLayer(tmp.path, directory))) | ||
| // Effect.provide has closed the layer scope before this marker. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: Comment on layer scope closure could be more explicit The comment Suggest: Reply with |
||
| yield* Effect.sync(() => phase(`${name}-layer:done`)) | ||
| return result | ||
| }) | ||
| expect(yield* capture(project, "project")).toBeDefined() | ||
| expect(yield* capture(linked, "linked")).toBeDefined() | ||
|
|
||
| yield* Effect.sync(() => phase("project-id:start")) | ||
| const projectID = yield* Effect.gen(function* () { | ||
| return (yield* Location.Service).project.id | ||
| }).pipe( | ||
| Effect.provide( | ||
| AppNodeBuilder.build(Location.boundNode(Location.Ref.make({ directory: AbsolutePath.make(project) }))), | ||
| ), | ||
| ) | ||
| yield* Effect.sync(() => phase("project-id:done")) | ||
| yield* Effect.sync(() => phase("indexes:start")) | ||
| expect( | ||
| yield* Effect.promise(() => fs.stat(path.join(tmp.path, "snapshot", projectID, Hash.fast(project)))), | ||
| ).toBeDefined() | ||
| expect( | ||
| yield* Effect.promise(() => fs.stat(path.join(tmp.path, "snapshot", projectID, Hash.fast(linked)))), | ||
| ).toBeDefined() | ||
| yield* Effect.sync(() => phase("indexes:done")) | ||
| }), | ||
| (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()), | ||
| ), | ||
| ) | ||
| (tmp) => | ||
| Effect.promise(async () => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Cleanup swallows potential disposal errors without logging The release function uses Consider wrapping the disposal in a try/catch to emit a Reply with |
||
| phase("cleanup:start") | ||
| await tmp[Symbol.asyncDispose]() | ||
| phase("cleanup:done") | ||
| }), | ||
| ) | ||
| }) | ||
|
|
||
| testEffect(Layer.empty).live("checks out a legacy revert snapshot without removing unrelated files", () => | ||
| Effect.acquireUseRelease( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUGGESTION: Test relies on default 5-second timeout without explicit declaration
The first test explicitly sets a 30-second timeout (line 83:
}, 30_000)). This test omits the timeout argument, relying ontestEffect's default (5 seconds per PR description). Given the extensive Git operations (init, config, add, commit, worktree add), this may timeout on slow CI — which appears intentional for diagnostics, but the intent is not documented in the test signature.Consider adding an explicit timeout (or
Infinityto disable) with a comment explaining the diagnostic purpose.Reply with
@kilocode-bot fix itto have Kilo Code address this issue.