Initial import of NousResearch/hermes-agent
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Docker / shell lint / Lint Dockerfile (hadolint) (push) Has been cancelled
Docker / shell lint / Lint docker/ shell scripts (shellcheck) (push) Has been cancelled
Docker Build and Publish / build-amd64 (push) Has been cancelled
Docker Build and Publish / build-arm64 (push) Has been cancelled
Lint (ruff + ty) / ruff + ty diff (push) Has been cancelled
Lint (ruff + ty) / ruff enforcement (blocking) (push) Has been cancelled
Lint (ruff + ty) / Windows footguns (blocking) (push) Has been cancelled
Nix Lockfile Fix / auto-fix-main (push) Has been cancelled
Nix Lockfile Fix / fix (push) Has been cancelled
Nix / nix (macos-latest) (push) Has been cancelled
Nix / nix (ubuntu-latest) (push) Has been cancelled
OSV-Scanner / Scan lockfiles (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Tests / test (1) (push) Has been cancelled
Tests / test (2) (push) Has been cancelled
Tests / test (3) (push) Has been cancelled
Tests / test (4) (push) Has been cancelled
Tests / test (5) (push) Has been cancelled
Tests / test (6) (push) Has been cancelled
Tests / e2e (push) Has been cancelled
uv.lock check / uv lock --check (push) Has been cancelled
Docker Build and Publish / merge (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Tests / save-durations (push) Has been cancelled

This commit is contained in:
红尘
2026-05-31 09:36:58 +08:00
commit d73ff9b0fb
4188 changed files with 1614916 additions and 0 deletions
@@ -0,0 +1,67 @@
"""Coverage for _run_with_idle_timeout — the streaming subprocess helper.
Kept in a dedicated test file because the tests spawn real ``subprocess.Popen``
instances; pytest-isolate runs each test file in its own worker process, so
isolating these here prevents real-Popen state from racing with the
``subprocess.run`` / ``_run_with_idle_timeout`` patches used by
``test_web_ui_build.py``.
Added for issue #33788: ``hermes update`` got stuck at "webui-build" because
``npm run build`` ran with ``capture_output=True`` and no timeout. The helper
fixes both halves — streams output AND idle-kills the process.
"""
import sys as _sys
import time
from hermes_cli.main import _run_with_idle_timeout
def test_streams_output_and_returns_zero_on_success(tmp_path):
script = tmp_path / "ok.py"
script.write_text("print('line one'); print('line two')\n")
result = _run_with_idle_timeout(
[_sys.executable, str(script)], cwd=tmp_path, idle_timeout_seconds=10
)
assert result.returncode == 0
assert "line one" in result.stdout
assert "line two" in result.stdout
def test_propagates_nonzero_exit(tmp_path):
script = tmp_path / "fail.py"
script.write_text("import sys; print('boom', file=sys.stderr); sys.exit(7)\n")
result = _run_with_idle_timeout(
[_sys.executable, str(script)], cwd=tmp_path, idle_timeout_seconds=10
)
assert result.returncode == 7
# stderr is merged into stdout in the helper.
assert "boom" in result.stdout
def test_kills_process_on_idle_timeout(tmp_path):
# Sleeps without printing — exactly the failure mode users see when
# `npm run build` stalls. Idle timeout must terminate it.
script = tmp_path / "stall.py"
script.write_text("import time; time.sleep(30)\n")
start = time.monotonic()
result = _run_with_idle_timeout(
[_sys.executable, str(script)],
cwd=tmp_path,
idle_timeout_seconds=1,
)
elapsed = time.monotonic() - start
# Should have died well before the 30s sleep completes.
assert elapsed < 15
assert result.returncode != 0
assert "produced no output" in result.stdout
def test_returns_127_when_binary_missing(tmp_path):
result = _run_with_idle_timeout(
["/nonexistent/binary/does/not/exist"],
cwd=tmp_path,
idle_timeout_seconds=5,
)
assert result.returncode == 127