Repository navigation
test(sessions): run the session lock test on Windows and add a cross-process one - #1115
Merged
kevincodex1 merged 2 commits intoOct 14, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The helper may release its lock early because the lock-retaining closure is not kept alive.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds Windows and cross-process coverage for session file locking.
Changes:
- Enables the existing cross-store lock test on Windows.
- Adds a helper-process test for lock release on process exit.
| File | Description |
|---|---|
internal/sessions/rewind_test.go |
Removes the Windows test skip. |
internal/sessions/filelock_process_test.go |
Adds cross-process lock coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Member
|
please address copilot comments |
…process one TestSessionFileLockSerializesAcrossStores was skipped on Windows with "flock semantics differ on windows", so the LockFileEx path in filelock_windows.go was never exercised by a test on the platform that uses it. LockFileEx locks are per handle, which is what the test relies on, so the skip was unnecessary: remove it. Also add a helper-process test (same pattern as lockutil's) proving the session lock blocks a different process and is released by the OS when the holder exits without unlocking. Both fail on Windows when the lock is replaced by a no-op. Fixes Twigpine#1104 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The helper discarded the unlock closure returned by lockSession, which is the only reference to the open lock file/handle. GC finalization could close it while the helper waits on stdin, releasing the OS lock early and making the cross-process test pass for the wrong reason. Retain the closure and runtime.KeepAlive it after io.Copy, as the lockutil helper does.
PierrunoYT
force-pushed
the
test/sessions-windows-lock
branch
from
October 14, 2026 10:56
5709d13 to
921342e
Compare
Contributor
Author
|
@kevincodex1 The Copilot comment is addressed in 921342e: the helper now keeps the |
kevincodex1
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
TestSessionFileLockSerializesAcrossStoreswas skipped on Windows (flock semantics differ on windows), so theLockFileEximplementation ininternal/sessions/filelock_windows.gowas never covered by a test on the only platform that uses it.The skip was not needed:
LockFileExlocks are per handle, and twoStoreinstances open separate handles, so the test's expectation (the second store'sAppendEventblocks until the first releases) holds on Windows. This PR removes the skip.It also adds
TestSessionFileLockBlocksAnotherProcessUntilItExits, a helper-process test in the same style aslockutil_test.go: a child process takes the session lock and exits without unlocking, and the parent checks that itsAppendEventblocks while the child holds the lock and proceeds once the child exits (the OS releases the lock). It runs on all platforms.Test-only change. The other skips the issue lists (
oauth/store_test.go,config/writer_test.go) and migratingsessionsontolockutilare not included.Linked issue
Fixes #1104
Note: #1104 does not currently carry the
issue-approvedlabel. Opening this anyway at the author's request; it can be held until the issue is approved.Verification
LockFileExcall with a no-op makes both fail (storeB AppendEvent completed while storeA held the OS lock, andAppendEvent completed while another process held the session lock); the original code was restored afterwards. So the tests now guard the Windows lock.go build ./...,go vet ./internal/sessions/,gofmt -l internal/sessions,git diff --cached --checkclean;go test ./internal/sessions/passes.flock) should behave the same for both tests, but that is left to CI.-race, fullgo test ./..., smoke andmaketargets were not run locally.Checklist
issue-approvedlabel. (not yet)go build ./...,go vet ./..., andgo test ./...pass locally. (build passes; vet and tests only forinternal/sessions)gofmtclean.-racewhere relevant). (tests added;-racenot run locally)🤖 Generated with Claude Code
Summary by CodeRabbit