Skip to content

test(sessions): run the session lock test on Windows and add a cross-process one - #1115

Open
PierrunoYT wants to merge 1 commit into
Twigpine:mainfrom
PierrunoYT:test/sessions-windows-lock
Open

PierrunoYT wants to merge 1 commit into
Twigpine:mainfrom
PierrunoYT:test/sessions-windows-lock

Conversation

@PierrunoYT

Copy link
Copy Markdown
Contributor

Summary

TestSessionFileLockSerializesAcrossStores was skipped on Windows (flock semantics differ on windows), so the LockFileEx implementation in internal/sessions/filelock_windows.go was never covered by a test on the only platform that uses it.

The skip was not needed: LockFileEx locks are per handle, and two Store instances open separate handles, so the test's expectation (the second store's AppendEvent blocks until the first releases) holds on Windows. This PR removes the skip.

It also adds TestSessionFileLockBlocksAnotherProcessUntilItExits, a helper-process test in the same style as lockutil_test.go: a child process takes the session lock and exits without unlocking, and the parent checks that its AppendEvent blocks 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 migrating sessions onto lockutil are not included.

Linked issue

Fixes #1104

Note: #1104 does not currently carry the issue-approved label. Opening this anyway at the author's request; it can be held until the issue is approved.

Verification

  • Both tests pass on Windows; the unskipped test passed 20 of 20 runs, the new one 10 of 10.
  • Mutation check on Windows: replacing the LockFileEx call with a no-op makes both fail (storeB AppendEvent completed while storeA held the OS lock, and AppendEvent 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 --check clean; go test ./internal/sessions/ passes.
  • Only run on Windows. The unix path (flock) should behave the same for both tests, but that is left to CI. -race, full go test ./..., smoke and make targets were not run locally.

Checklist

  • The linked issue already has the issue-approved label. (not yet)
  • go build ./..., go vet ./..., and go test ./... pass locally. (build passes; vet and tests only for internal/sessions)
  • gofmt clean.
  • Tests added/updated for the change (and run under -race where relevant). (tests added; -race not run locally)
  • UI changes include screenshots or a short recording where possible. (no UI change)

🤖 Generated with Claude Code

…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>
Copilot AI balanced review requested due to automatic review settings October 2, 2026 17:58
@coderabbitai

coderabbitai Bot commented Oct 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.

Next included review available in 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: Twigpine/zero/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: cc066eab-e240-4a5c-89b3-d066c054e41d

📥 Commits

Reviewing files that changed from the base of the PR and between 99721c7 and 5709d13.

📒 Files selected for processing (2)
  • internal/sessions/filelock_process_test.go
  • internal/sessions/rewind_test.go
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Medium severity

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.

return
}
store := NewStore(StoreOptions{RootDir: os.Getenv("ZERO_SESSIONS_LOCK_ROOT")})
if _, err := store.lockSession("s"); err != nil {

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows cross-process session lock test is skipped on Windows

2 participants