34 lines
1.8 KiB
Bash
Executable File
34 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
# M4 e2e: ruff lint findings reach the model, ruff-format runs without tripping the read-guard,
|
|
# diag_mark persists and hides the finding.
|
|
set -eu
|
|
command -v ruff >/dev/null || { echo "skip: ruff not installed"; exit 0; }
|
|
root=$(cd "$(dirname "$0")/.." && pwd)
|
|
tmp=$(mktemp -d)
|
|
trap 'kill $srv 2>/dev/null; rm -rf "$tmp"' EXIT
|
|
port=$((20000 + $$ % 20000))
|
|
python3 "$root/tests/fake_m4.py" $port & srv=$!
|
|
mkdir -p "$tmp/home/.hx" "$tmp/repo"
|
|
echo '{"claude":{"access":"fake-token","refresh":"r","expires":99999999999999}}' > "$tmp/home/.hx/auth.json"
|
|
# ruff.toml enables ruff-format (formatters only run when configured)
|
|
echo 'line-length = 100' > "$tmp/repo/ruff.toml"
|
|
printf '[lsp]\ndisable = ["pyright"]\n' > "$tmp/home/.hx/config.toml"
|
|
sleep 0.5
|
|
cd "$tmp/repo"
|
|
HOME="$tmp/home" HX_BASE_URL="http://127.0.0.1:$port" "$root/target/debug/hx" -p "go" > "$tmp/out" 2> "$tmp/err" || { cat "$tmp/err"; exit 1; }
|
|
log="$tmp/log.json"
|
|
curl -s "http://127.0.0.1:$port/" > "$log"
|
|
fail() { echo "FAIL: $1"; echo "--- log"; python3 -m json.tool < "$log"; echo "--- err"; cat "$tmp/err"; exit 1; }
|
|
chk() { python3 -c "import json,sys; l=json.load(open(sys.argv[1])); $1" "$log"; }
|
|
grep -q FINISHED "$tmp/out" || fail "no finish"
|
|
# turn 2 request carries lens report with ruff F401
|
|
chk 'assert "[F401]" in l[1] and "(ruff)" in l[1], l[1]' || fail "no ruff finding"
|
|
# formatter applied, and the following edit was not blocked
|
|
grep -qx "x = 2" p.py && grep -qx "print(x)" p.py || fail "format/edit: $(cat p.py)"
|
|
chk 'assert l[2].startswith("OK:edited"), l[2]' || fail "edit blocked"
|
|
# diag_mark succeeded and persisted
|
|
chk 'assert "OK:marked FalsePositive" in l[3], l[3]' || fail "mark"
|
|
grep -q F401 "$tmp"/home/.hx/projects/*/triage.json || fail "triage not persisted"
|
|
[ -s "$tmp/home/.hx/latency.log" ] || fail "no latency log"
|
|
echo "m4 e2e ok"
|