Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions bench/test_run_arm_guard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""run_arm.sh refuses an arm NAME that starts with '-'.

`scripts/run_arm.sh --help` used to start a real arm named "--help" against
the current catalog (2026-10-09): the name check allowed a leading dash. The
guard must fire before anything is started, so this runs the script itself.
"""
import pathlib
import subprocess

import pytest

SCRIPT = pathlib.Path(__file__).resolve().parent.parent / "scripts" / "run_arm.sh"


@pytest.mark.parametrize("name", ["--help", "-h", "-x"])
def test_a_leading_dash_is_refused_before_anything_runs(name):
r = subprocess.run(["bash", str(SCRIPT), name], capture_output=True, text=True, timeout=30)
assert r.returncode == 1
assert "not start with '-'" in r.stderr
assert "usage:" in r.stderr
4 changes: 3 additions & 1 deletion scripts/run_arm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ die() { echo "run_arm: $*" >&2; exit 1; }

[ $# -ge 1 ] || die "usage: scripts/run_arm.sh NAME [--server K=V]... [--bench K=V]... [--port N]"
NAME=$1; shift
[[ "$NAME" =~ ^[A-Za-z0-9._-]+$ ]] || die "NAME must be [A-Za-z0-9._-]+"
# A leading '-' is refused: `run_arm.sh --help` used to start a real arm named
# "--help" on the current catalog (2026-10-09).
[[ "$NAME" =~ ^[A-Za-z0-9._][A-Za-z0-9._-]*$ ]] || die "NAME must be [A-Za-z0-9._-]+ and not start with '-' (usage: scripts/run_arm.sh NAME [--server K=V]... [--bench K=V]... [--port N] [--catalog ID] [--max-edges N])"
SERVER=(); BENCH=(); PORT=8090; LIMIT=(); CATALOG_ID=""; MAX_EDGES=40000
while [ $# -gt 0 ]; do
case "$1" in
Expand Down
Loading