Files
hermes-agent/tests/scripts/test_ruff_runner_cli.py
alt-glitch ec7c695d4c feat(dev): just lists the developer commands; lefthook calls its recipes
The justfile held per-workspace eslint recipes that duplicated lefthook and
ran whatever ruff was on PATH. It is now one menu of developer commands:
setup, check, fix, test, the JS workspace checks, the desktop and TUI dev
servers, the website build and the PM re-lock. Each recipe calls an existing
script or tool. Python recipes go through scripts/run-in-hermes-env, so they
work in a shell that never ran `source ./activate`.

`just test` requires at least one path, because scripts/run_tests.sh with no
arguments starts the full suite; `just test-all` is that explicit form.

`python -m scripts.code_health.ruff_runner ARGS` runs the pyproject-pinned ruff
that scripts/check resolves. `just fix` and the pre-commit `just ruff` recipe
use it, so the hook no longer depends on the ruff version on PATH.

lefthook.yml keeps its jobs, globs and roots; each job now runs `just ruff` or
`just eslint`. A shell without `just` on PATH fails the hook with "command not
found" rather than skipping the lint.

CONTRIBUTING.md, the developer guide, the package-management reference and the
desktop and TUI READMEs name the recipes beside the commands they run.
2026-11-09 16:34:44 +05:30

33 lines
1.2 KiB
Python

"""``python -m scripts.code_health.ruff_runner`` runs the pyproject-pinned ruff, whatever is on PATH."""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
from scripts.code_health.ruff_runner import pinned_version
REPO = Path(__file__).resolve().parents[2]
def test_module_runs_the_pinned_ruff_with_the_given_arguments() -> None:
proc = subprocess.run(
[sys.executable, "-m", "scripts.code_health.ruff_runner", "--version"],
cwd=REPO, capture_output=True, text=True, timeout=300, stdin=subprocess.DEVNULL, check=False,
)
assert proc.returncode == 0, proc.stderr
assert proc.stdout.split() == ["ruff", pinned_version(REPO)]
def test_module_forwards_the_ruff_exit_status(tmp_path: Path) -> None:
bad = tmp_path / "bad.py"
bad.write_text("import os\n", encoding="utf-8")
proc = subprocess.run(
[sys.executable, "-m", "scripts.code_health.ruff_runner", "check", "--isolated",
"--no-cache", "--select", "F401", str(bad)],
cwd=REPO, capture_output=True, text=True, timeout=300, stdin=subprocess.DEVNULL, check=False,
)
assert proc.returncode == 1, proc.stdout + proc.stderr
assert "F401" in proc.stdout