From f00dc6d7a3a1d1a1cc5e98507d2efb201990f517 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sat, 9 May 2026 12:47:52 -0700 Subject: [PATCH] =?UTF-8?q?fix(tests):=20harden=20run=5Ftests.sh=20?= =?UTF-8?q?=E2=80=94=20uv-aware=20bootstrap=20+=20scrub=20HERMES=5FCRON=5F?= =?UTF-8?q?SESSION=20(#22767)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two unrelated but co-located fixes to scripts/run_tests.sh: 1. pytest-split bootstrap (#22401): the script tried '$PYTHON -m pip install pytest-split' on first run, but uv-created venvs ship without pip. Result: 'No module named pip' before any test ran. Add a uv fallback (uv pip install --python $PYTHON), keep pip as a secondary path, and emit a clear error pointing at 'uv pip install -e ".[dev]"' when neither is available. Also declare pytest-split in pyproject.toml dev extra so a normal '.[dev]' install provisions it. 2. HERMES_CRON_SESSION leak (#22400): the hermetic env scrub already unsets HERMES_GATEWAY_SESSION and HERMES_INTERACTIVE but missed the sibling HERMES_CRON_SESSION. When run_tests.sh is invoked from a Hermes cron job, that variable leaks into pytest, flipping tools/approval.py into cron-deny mode and breaking tests/acp/test_approval_isolation.py and friends. Closes #22400. Closes #22401. --- pyproject.toml | 2 +- scripts/run_tests.sh | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6d1a3e1ec2e..0576bac779c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ dependencies = [ modal = ["modal>=1.0.0,<2"] daytona = ["daytona>=0.148.0,<1"] vercel = ["vercel>=0.5.7,<0.6.0"] -dev = ["debugpy>=1.8.0,<2", "pytest>=9.0.2,<10", "pytest-asyncio>=1.3.0,<2", "pytest-xdist>=3.0,<4", "mcp>=1.2.0,<2", "ty>=0.0.1a29,<0.0.22", "ruff"] +dev = ["debugpy>=1.8.0,<2", "pytest>=9.0.2,<10", "pytest-asyncio>=1.3.0,<2", "pytest-xdist>=3.0,<4", "pytest-split>=0.9,<1", "mcp>=1.2.0,<2", "ty>=0.0.1a29,<0.0.22", "ruff"] messaging = ["python-telegram-bot[webhooks]>=22.6,<23", "discord.py[voice]>=2.7.1,<3", "aiohttp>=3.13.3,<4", "slack-bolt>=1.18.0,<2", "slack-sdk>=3.27.0,<4", "qrcode>=7.0,<8"] cron = [] # croniter is now a core dependency; this extra kept for back-compat slack = ["slack-bolt>=1.18.0,<2", "slack-sdk>=3.27.0,<4"] diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 0ad2dc464bd..d7d8a85f502 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -44,7 +44,15 @@ PYTHON="$VENV/bin/python" # ── Ensure pytest-split is installed (required for shard-equivalent runs) ── if ! "$PYTHON" -c "import pytest_split" 2>/dev/null; then echo "→ installing pytest-split into $VENV" - "$PYTHON" -m pip install --quiet "pytest-split>=0.9,<1" + if command -v uv >/dev/null 2>&1; then + uv pip install --python "$PYTHON" --quiet "pytest-split>=0.9,<1" + elif "$PYTHON" -m pip --version >/dev/null 2>&1; then + "$PYTHON" -m pip install --quiet "pytest-split>=0.9,<1" + else + echo "error: neither uv nor pip is available in $VENV — pytest-split is missing" >&2 + echo " fix: run uv pip install -e \".[dev]\" from $REPO_ROOT" >&2 + exit 1 + fi fi # ── Hermetic environment ──────────────────────────────────────────────────── @@ -67,6 +75,7 @@ unset HERMES_YOLO_MODE HERMES_INTERACTIVE HERMES_QUIET HERMES_TOOL_PROGRESS \ HERMES_TOOL_PROGRESS_MODE HERMES_MAX_ITERATIONS HERMES_SESSION_PLATFORM \ HERMES_SESSION_CHAT_ID HERMES_SESSION_CHAT_NAME HERMES_SESSION_THREAD_ID \ HERMES_SESSION_SOURCE HERMES_SESSION_KEY HERMES_GATEWAY_SESSION \ + HERMES_CRON_SESSION \ HERMES_PLATFORM HERMES_INFERENCE_PROVIDER HERMES_MANAGED HERMES_DEV \ HERMES_CONTAINER HERMES_EPHEMERAL_SYSTEM_PROMPT HERMES_TIMEZONE \ HERMES_REDACT_SECRETS HERMES_BACKGROUND_NOTIFICATIONS HERMES_EXEC_ASK \