Skip to content

Commit 47a0563

Browse files
author
lpb-docs
committed
test(devstack): isolate bump tests from real workspace (release gate)
_devstack_root_patch now also patches repos.WORKSPACE_ROOT / DEFAULT_AGENT_DIR — without it the bump gate inspects the developer's real workspace and the bump tests fail whenever local checkouts are dirty or unpushed (CI never saw it: empty checkout skips all repos).
1 parent c7f1b13 commit 47a0563

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

scripts/test_localpibox_devstack.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,37 @@
77

88
import os
99
import subprocess
10+
from contextlib import ExitStack
1011
from unittest import mock
1112

1213
from localpibox.stack import version as ver_mod
1314
from localpibox.stack import workspace as ws_mod
1415
from localpibox.stack import release as rel_mod
16+
from localpibox.stack import repos as repos_mod
1517

1618
ld = _load_script('lpb_devstack', SCRIPTS_DIR / 'lpb-devstack')
1719

1820
# ─── lpb-devstack: VERSION bumping ────────────────────────────────────────
1921

2022
def _devstack_root_patch(root, tmpdir):
21-
"""Point stack version discovery at *root* (context manager)."""
22-
return mock.patch.multiple(
23-
ver_mod,
24-
_DEVSTACK_ROOT=root,
25-
WORKSPACE_ROOT=tmpdir / "nowhere",
26-
_VERSION_FILE=None,
27-
)
23+
"""Point stack version discovery at *root* (context manager).
24+
25+
Also neutralizes the dev release gate: without patching repo_path, the
26+
gate inspects the *real* workspace (its own module-level roots), so a
27+
dirty or unpushed local checkout would make the bump tests fail.
28+
"""
29+
stack = ExitStack()
30+
stack.enter_context(mock.patch.object(ver_mod, "_DEVSTACK_ROOT", root))
31+
stack.enter_context(mock.patch.object(ver_mod, "WORKSPACE_ROOT", tmpdir / "nowhere"))
32+
stack.enter_context(mock.patch.object(ver_mod, "_VERSION_FILE", None))
33+
# repo_path() resolves against repos.* at call time — patch its roots so
34+
# the gate finds no local clones (tests that need a fake gate repo patch
35+
# rel_mod.repo_path directly, which still wins).
36+
stack.enter_context(mock.patch.object(
37+
repos_mod, "WORKSPACE_ROOT", tmpdir / "nowhere"))
38+
stack.enter_context(mock.patch.object(
39+
repos_mod, "DEFAULT_AGENT_DIR", str(tmpdir / "agent")))
40+
return stack
2841

2942

3043
def test_devstack_bump_patch(tmpdir):

0 commit comments

Comments
 (0)