Skip to content

test(windows): skipif POSIX-only unlink semantics in test_force_overrides_db_lock (#643 cluster H-2)#729

Merged
memtomem merged 1 commit intomainfrom
test/windows-skip-force-db-lock
May 2, 2026
Merged

test(windows): skipif POSIX-only unlink semantics in test_force_overrides_db_lock (#643 cluster H-2)#729
memtomem merged 1 commit intomainfrom
test/windows-skip-force-db-lock

Conversation

@memtomem
Copy link
Copy Markdown
Owner

@memtomem memtomem commented May 2, 2026

Summary

Cluster H-2 of #643test_force_overrides_db_lock relies on POSIX unlink-while-open semantics that don't exist on Windows.

The test holds a sqlite3 BEGIN IMMEDIATE write lock in the same process, then invokes mm uninstall -y --force and asserts the state directory was wiped. On POSIX rmtree succeeds because the directory entry is gone even though the inode is still open via the live connection. On Windows the same unlink raises:

[WinError 32] The process cannot access the file because it is being
used by another process: ...\memtomem.db

Sibling tests in TestDbWriterLockRefuses (test_refuses_when_writer_holds_lock, test_proceeds_when_db_exists_but_no_writer) already pass on Windows and cover the lock-detection path. This is a method-level skip rather than class-wide.

Approach

@pytest.mark.skipif(
    sys.platform == "win32",
    reason=(
        "Test relies on POSIX unlink-while-open semantics — Windows refuses "
        "to unlink a file held by an open handle (WinError 32), so --force "
        "cannot wipe the dir while the lock-holding connection lives in "
        "the same process. Sibling tests cover the lock-detection path."
    ),
)

sys already imported in the module (test_uninstall_cmd.py:15).

This is a test-only change — production behavior on Windows under --force against a live writer is a separate contract question, now tracked in #730 ("Windows: contract for mm uninstall --force against a live writer is undefined"). That issue documents the half-wipe failure mode ([WinError 32] mid-rmtree) and the three options for what --force should mean on Windows; this PR intentionally defers that decision and just unblocks CI.

Test plan

  • POSIX unchanged: uv run pytest packages/memtomem/tests/test_uninstall_cmd.py -v — 28/28 passed.
  • uv run ruff check + uv run ruff format --check on the touched file.
  • CI test (windows-latest) will skip test_force_overrides_db_lock (cluster H-2 of the Windows compat sweep).

After this lands, the only remaining windows-latest failures from the sha-88c3e81 run are cluster A (test_context_status.py, test_dirty.py — wiki dirty classification) — separate root cause.

🤖 Generated with Claude Code

…ides_db_lock (#643 cluster H-2)

The test relies on POSIX unlink-while-open semantics: ``--force`` wipes
the state directory while the lock-holding sqlite3 connection lives in
the same process. POSIX lets ``rmtree`` succeed because the directory
entry is gone even though the inode is still open. Windows refuses with

    [WinError 32] The process cannot access the file because it is being
    used by another process

Sibling tests in the same class (``test_refuses_when_writer_holds_lock``,
``test_proceeds_when_db_exists_but_no_writer``) pass on Windows and
already cover the lock-detection path, so this is a method-level skip
rather than a class-wide one.

This is a test-only change — production behavior on Windows under
``--force`` against a live writer is a separate question that no current
contract pins.

Co-Authored-By: Claude <[email protected]>
@memtomem memtomem merged commit d5b1fe3 into main May 2, 2026
8 of 9 checks passed
@memtomem memtomem deleted the test/windows-skip-force-db-lock branch May 2, 2026 11:26
@github-actions github-actions Bot locked and limited conversation to collaborators May 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants