Skip to content

The agent that grows with you

test(bot-mode): isolate fallback-ladder probes from the checkout's published launcher

Brooklyn Nicholson5ce2c7d5aa15
diff --git a/tests/tools/test_bot_mode_dm.py b/tests/tools/test_bot_mode_dm.py
index 17707bec9d6..a8722362f16 100644
--- a/tests/tools/test_bot_mode_dm.py
+++ b/tests/tools/test_bot_mode_dm.py
@@ -485,12 +485,16 @@ def test_delivery_pins_the_hermes_entrypoint_beside_this_interpreter(tmp_path, m
"""A background delivery must not rely on PATH: the runner's service context
lacks the gateway's venv bin dir, so a bare ``hermes`` resolves to a system
install whose shebang picks the wrong interpreter and dies on import (#108628).
- Both transports must invoke the entrypoint beside this interpreter instead."""
+ With no published install launcher, both transports invoke the entrypoint beside
+ this interpreter instead; a published launcher outranks that sibling (#124868)."""
venv_bin = tmp_path / "venv" / ("Scripts" if sys.platform == "win32" else "bin")
venv_bin.mkdir(parents=True)
hermes_entry = venv_bin / ("hermes.exe" if sys.platform == "win32" else "hermes")
hermes_entry.write_text("#!/bin/sh\n", encoding="utf-8")
monkeypatch.setattr(sys, "executable", str(venv_bin / "python3"))
+ # An install without a published launcher keeps the sibling fallback; keep this
+ # checkout's own published launcher out of the resolution (#124868).
+ monkeypatch.setattr(bot_relay, "__file__", str(tmp_path / "tools" / "bot_relay.py"))
calls = _capture_spawn(monkeypatch)
home = _managed_home(tmp_path, teammates=("researcher",), peers=("spark",))
diff --git a/tests/tools/test_bot_relay_windows_paths.py b/tests/tools/test_bot_relay_windows_paths.py
index aa0086e687f..ba29cb1944f 100644
--- a/tests/tools/test_bot_relay_windows_paths.py
+++ b/tests/tools/test_bot_relay_windows_paths.py
@@ -64,6 +64,9 @@ def test_local_delivery_uses_shutil_which_when_no_sibling(tmp_path, monkeypatch)
empty = tmp_path / "nowhere"
empty.mkdir(parents=True)
monkeypatch.setattr("sys.executable", str(empty / "python"))
+ # Keep this checkout's own published install launcher out of the resolution
+ # when probing the fallback ladder (#124868).
+ monkeypatch.setattr(bot_relay, "__file__", str(empty / "bot_relay.py"))
which_hit = str(tmp_path / "usr-local-bin" / "hermes")
monkeypatch.setattr(
bot_relay.shutil, "which", lambda name: which_hit if name == "hermes" else None
@@ -78,6 +81,7 @@ def test_local_delivery_falls_back_to_bare_name(tmp_path, monkeypatch):
empty.mkdir(parents=True)
monkeypatch.setattr("sys.executable", str(empty / "python"))
monkeypatch.setattr(bot_relay.shutil, "which", lambda name: None)
+ monkeypatch.setattr(bot_relay, "__file__", str(empty / "bot_relay.py"))
argv = bot_relay.local_delivery_command("ops", "query.json")
assert argv[0] == "hermes"