From d9b64a114aac28da01f63d3160ab6218d13ffef2 Mon Sep 17 00:00:00 2001 From: Trent Davies Date: Wed, 25 Mar 2026 09:10:12 -0600 Subject: [PATCH] fix test_named_agents by writing fake agent PATH to shell RC file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New tmux panes start a fresh shell that sources .zshrc/.bashrc, so fake agent binaries must be on PATH there — not just in the tmux global environment. Matches the pattern used by test_agents.py. Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/test_workmux_add/test_named_agents.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_workmux_add/test_named_agents.py b/tests/test_workmux_add/test_named_agents.py index 64009535..fdf0d9f5 100644 --- a/tests/test_workmux_add/test_named_agents.py +++ b/tests/test_workmux_add/test_named_agents.py @@ -1,5 +1,6 @@ """Tests for known agent auto-detection and prompt injection.""" +import os import shlex from pathlib import Path @@ -13,6 +14,15 @@ from .conftest import add_branch_and_get_worktree +def _write_rc_with_fake_path(env: MuxEnvironment, bin_dir: Path) -> None: + """Write a shell RC file that prepends the fake agent bin dir to PATH.""" + shell = os.environ.get("SHELL", "/bin/zsh") + rc_filename = ".zshrc" if "zsh" in shell else ".bashrc" + rc_path = env.home_path / rc_filename + rc_path.parent.mkdir(parents=True, exist_ok=True) + rc_path.write_text(f'export PATH="{bin_dir}:$PATH"\n') + + class TestKnownAgentAutoDetection: """Tests that literal known agent commands auto-detect for prompt injection.""" @@ -37,6 +47,9 @@ def test_literal_known_agent_gets_prompt_injection( """, ) + # Write RC file so new panes find the fake agent on PATH + _write_rc_with_fake_path(env, fake_agent_installer.bin_dir) + # Use literal "claude" in panes -- no placeholder, no global agent write_workmux_config( mux_repo_path, @@ -96,6 +109,9 @@ def test_two_known_agents_each_get_prompt( """, ) + # Write RC file so new panes find the fake agents on PATH + _write_rc_with_fake_path(env, fake_agent_installer.bin_dir) + write_workmux_config( mux_repo_path, panes=[