Skip to content

The agent that grows with you

fix: test-runner scratch lives in ~/.cache/hermes-pytest; env-less home fallback cannot raise

teknium10746903679f9
diff --git a/hermes_constants.py b/hermes_constants.py
index 94f65b86843..d911546a2a1 100644
--- a/hermes_constants.py
+++ b/hermes_constants.py
@@ -922,7 +922,11 @@ def get_real_home(env: dict[str, str] | None = None) -> str:
if not _is_profile_home(candidate, profile_home):
return candidate
import tempfile
- return tempfile.gettempdir()
+ try:
+ return tempfile.gettempdir()
+ except (RuntimeError, OSError):
+ # no HOME/USERPROFILE at all (env-less child on Windows): tempfile cannot expand ``~``
+ return "/tmp" # no-tmp: ok — last-resort fallback for an env with no home; not a write target we choose
_HOME_MODE_ALIASES = {"isolated": "profile", "profile_home": "profile", "profile-home": "profile",
diff --git a/scripts/run_tests_parallel.py b/scripts/run_tests_parallel.py
index f1727b46192..c7def2aa6b9 100755
--- a/scripts/run_tests_parallel.py
+++ b/scripts/run_tests_parallel.py
@@ -59,11 +59,13 @@ from pathlib import Path
from typing import Dict, List, Optional, Tuple
def _runner_scratch_root() -> str:
- """Per-run temp roots live under the developer's Hermes scratch dir, never the system
- temp dir: a full-suite run writes gigabytes of tmp_path fixtures, and /tmp is RAM-backed
- tmpfs on many Linux hosts. Resolved without importing the tree under test."""
- home = os.environ.get("HERMES_HOME") or os.path.join(os.path.expanduser("~"), ".hermes")
- root = os.path.join(home, "cache", "scratch", "pytest")
+ """Per-run temp roots live on disk under the user's cache dir, never the system temp dir:
+ a full-suite run writes gigabytes of tmp_path fixtures and /tmp is RAM-backed tmpfs on
+ many Linux hosts. Not under the Hermes home (conftest refuses a basetemp inside the live
+ install and would relocate it), and kept as short as the old /tmp root because tests that
+ bind AF_UNIX sockets under ``tempfile.mkdtemp()`` must stay within sun_path."""
+ cache = os.environ.get("XDG_CACHE_HOME") or os.path.join(os.path.expanduser("~"), ".cache")
+ root = os.path.join(cache, "hermes-pytest")
os.makedirs(root, exist_ok=True)
return root
@@ -462,7 +464,7 @@ def _run_one_file_once(
# One root for each subprocess removes the shared directory that the race
# needs. The parent deletes the root after the attempt.
env = os.environ.copy()
- temproot = tempfile.mkdtemp(prefix="hermes-pytest-tmproot-", dir=_runner_scratch_root())
+ temproot = tempfile.mkdtemp(prefix="r-", dir=_runner_scratch_root())
env["PYTEST_DEBUG_TEMPROOT"] = temproot
# Every tempfile.* call inside the test process lands in the same per-run root, so the
# parent's cleanup of ``temproot`` removes them too instead of leaving them in /tmp.
diff --git a/tests/gateway/test_status_command.py b/tests/gateway/test_status_command.py
index 98f615c473d..1846cc55d6a 100644
--- a/tests/gateway/test_status_command.py
+++ b/tests/gateway/test_status_command.py
@@ -624,7 +624,14 @@ async def test_profile_command_reports_source_stamped_profile(monkeypatch, tmp_p
result = await runner._handle_profile_command(event)
assert "**Profile:** `milo`" in result
- assert f"**Home:** `{profile_home}`" in result
+ # The reply renders display_hermes_home() for the routed profile, which abbreviates a home
+ # under $HOME to ``~/…``; compare against the same rendering rather than the raw path.
+ from gateway.run import _profile_runtime_scope
+ from hermes_constants import display_hermes_home
+
+ with _profile_runtime_scope(profile_home):
+ expected_home = display_hermes_home()
+ assert f"**Home:** `{expected_home}`" in result
# ── /context command tests ────────────────────────────────────────────────