b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
70 lines
2.6 KiB
Python
70 lines
2.6 KiB
Python
"""Tests for the strict gateway command-line matcher.
|
|
|
|
Regression guard for the Windows ``hermes gateway restart`` silent-outage bug:
|
|
the previous loose substring match (``"... gateway" in cmdline``) false-matched
|
|
``gateway status``/``dashboard`` siblings and unrelated processes such as
|
|
``python -m tui_gateway``, which let ``restart()`` race a still-draining old
|
|
process and ``status``/``start`` report false positives.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from gateway.status import (
|
|
looks_like_gateway_command_line as matches,
|
|
looks_like_gateway_runtime_command_line as matches_runtime,
|
|
)
|
|
|
|
|
|
ACCEPT = [
|
|
"pythonw.exe -m hermes_cli.main gateway run",
|
|
r"C:\Users\me\hermes\venv\Scripts\pythonw.exe -m hermes_cli.main gateway run",
|
|
"python -m hermes_cli.main --profile work gateway run",
|
|
"python -m hermes_cli.main gateway run --replace",
|
|
"python -m hermes_cli/main.py gateway run",
|
|
"python gateway/run.py",
|
|
"hermes-gateway.exe",
|
|
"hermes gateway", # bare `hermes gateway` defaults to run
|
|
"hermes gateway run",
|
|
# profile selector AFTER the `gateway` token (argv is profile-position
|
|
# agnostic — _apply_profile_override strips --profile/-p anywhere)
|
|
"hermes gateway --profile work run",
|
|
"python -m hermes_cli.main gateway -p work run",
|
|
"hermes gateway --profile=work run",
|
|
# a profile literally NAMED "gateway"
|
|
"hermes -p gateway gateway run",
|
|
"python -m hermes_cli.main --profile gateway gateway run",
|
|
# quoted Windows paths with spaces (shlex-aware tokenization)
|
|
r'"C:\Program Files\Hermes\hermes-gateway.exe"',
|
|
r'"C:\Program Files\Hermes\gateway\run.py" run',
|
|
r'"C:\Program Files\Py\pythonw.exe" -m hermes_cli.main gateway run',
|
|
]
|
|
|
|
REJECT = [
|
|
"python -m tui_gateway", # unrelated module
|
|
"python -m hermes_cli.main gateway status", # other subcommand
|
|
"python -m hermes_cli.main gateway restart",
|
|
"python -m hermes_cli.main gateway stop",
|
|
"python -m hermes_cli.main --profile x dashboard", # non-gateway subcommand
|
|
"some random python -m mygateway thing",
|
|
"",
|
|
None,
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize("cmd", ACCEPT)
|
|
def test_accepts_real_gateway_run(cmd):
|
|
assert matches(cmd) is True
|
|
|
|
|
|
@pytest.mark.parametrize("cmd", REJECT)
|
|
def test_rejects_non_gateway_run(cmd):
|
|
assert matches(cmd) is False
|
|
|
|
|
|
def test_runtime_matcher_accepts_no_supervisor_restart_process():
|
|
assert matches("python -m hermes_cli.main gateway restart") is False
|
|
assert matches_runtime("python -m hermes_cli.main gateway restart") is True
|
|
assert matches_runtime("python -m hermes_cli.main gateway status") is False
|