Skip to content

The agent that grows with you

test(update): give each test a private lock for this repo's checkout

Teknium0be954664fe5
diff --git a/tests/hermes_cli/conftest.py b/tests/hermes_cli/conftest.py
index e45fcc0aae4..a230a89d22c 100644
--- a/tests/hermes_cli/conftest.py
+++ b/tests/hermes_cli/conftest.py
@@ -56,6 +56,27 @@ def _suppress_concurrent_hermes_gate(request, monkeypatch):
)
[email protected](autouse=True)
+def _private_repo_checkout_lock(monkeypatch, tmp_path_factory):
+ """``cmd_update`` locks the checkout it runs from: in tests, this repository, whose git
+ common dir every parallel test process (and, from a linked worktree, the live install's
+ ``hermes update``) shares. Give each test its own lock file for THIS repo; lock tests on
+ fixture checkouts are unaffected."""
+ from pathlib import Path
+
+ from hermes_cli import update_lock
+
+ repo = Path(update_lock.__file__).resolve().parents[1]
+ real = update_lock.checkout_lock_path
+ private = tmp_path_factory.mktemp("checkout-lock") / "hermes-update.lock"
+
+ def checkout_lock_path(install_root=None):
+ root = Path(install_root) if install_root else repo
+ return private if root.resolve() == repo else real(install_root)
+
+ monkeypatch.setattr(update_lock, "checkout_lock_path", checkout_lock_path)
+
+
@pytest.fixture(autouse=True)
def _source_channels_resolve_locally(request, monkeypatch):
"""Every unflagged ``hermes update`` resolves its channel through R2; tests must
diff --git a/tests/hermes_cli/test_update_receipt.py b/tests/hermes_cli/test_update_receipt.py
index 52ca9177653..f2bfbc90e84 100644
--- a/tests/hermes_cli/test_update_receipt.py
+++ b/tests/hermes_cli/test_update_receipt.py
@@ -214,6 +214,9 @@ class TestCommandBoundaryFinalization:
class _FakeLock:
holder = None
+ def __init__(self, **_kw): # cmd_update passes install_root
+ pass
+
def acquire(self):
return True