diff --git a/tools/test-tools.sh b/tools/test-tools.sh index 60c6ab7..235ff68 100644 --- a/tools/test-tools.sh +++ b/tools/test-tools.sh @@ -235,8 +235,7 @@ g() { git -C "$R" -c user.name=t -c user.email=t@t -c core.autocrlf=false "$@" > seqf() { local i; for i in $(seq 1 "$2"); do echo "$1$i"; done; } g init -q seqf a 40 >"$R/a.txt"; seqf b 40 >"$R/b.txt"; seqf c 10 >"$R/c.txt"; seqf d 20 >"$R/d.txt" -seqf e 10 >"$R/e.txt"; seqf f 20 >"$R/f.txt"; seqf g 300 >"$R/big.txt"; seqf h 5 | sed 's/$/ -/' >"$R/h.txt"; seqf m 40 >"$R/m.txt" +seqf e 10 >"$R/e.txt"; seqf f 20 >"$R/f.txt"; seqf g 300 >"$R/big.txt"; seqf h 5 | sed 's/$/ /' >"$R/h.txt"; seqf m 40 >"$R/m.txt" g add -A; g commit -q -m base; BASE=$(git -C "$R" rev-parse HEAD) { sed -n 1,5p "$R/a.txt"; printf 'ins1\nins2\nins3\n'; sed -n '6,$p' "$R/a.txt"; } >"$R/a.new"; mv "$R/a.new" "$R/a.txt" sed -e '2,3d' -e 's/^b10$/b10-EDITED/' "$R/b.txt" >"$R/b.new"; mv "$R/b.new" "$R/b.txt" @@ -277,8 +276,7 @@ cin "hunk ending just before the range shifts it" "[23] b.txt:4-5 MOVED(-2) -> cin "NEW file present in the worktree gets a window" "== [24] n.txt:1-2" cin "NEW window shows the file" " 2 n2" cin "CRLF window text" " 2 h2" -{ tr -d ' -' <"$T/cp.out" | cmp -s - "$T/cp.out"; } && echo "ok context-pack CRLF is stripped from windows" || { echo "FAIL context-pack CR in output"; fail=1; } +{ tr -d ' ' <"$T/cp.out" | cmp -s - "$T/cp.out"; } && echo "ok context-pack CRLF is stripped from windows" || { echo "FAIL context-pack CR in output"; fail=1; } cin "window numbers are worktree lines" " 6 b8" cin "window shows the edit" "b10-EDITED" cin "GONE window is labelled AT BASE" "== [7] c.txt:2-3 AT BASE" @@ -903,6 +901,7 @@ check("R4 the first agent's retry still passes", silent(r) and calls == []) # R2 nothing to check: zero calls, empty stdout for label, hh, kw in [("a batch with no ruling or question", hook([doc("finding", "f", "x"), doc("cut_report", "c", "y")]), {}), ("an empty batch", hook([]), {}), + ("a ruling with an empty title", hook([doc("ruling", "x", "")]), {}), ("a ruling with no title", hook([{"kind": "ruling", "value": {"campaign": "t", "label": "x"}}]), {}), ("a tool other than admit", hook([mine], tool_name="mcp__eureka-state__view"), {}), ("malformed stdin", None, {"stdin": b"not json"}), @@ -957,9 +956,12 @@ r, calls, ms = run(hook(five)) check("R8 five rulings make three queries, the first three titles, and the reason counts two unchecked", len(calls) == 3 and sorted(c["semantic"]["text"] for c in calls) == ["Title 0", "Title 1", "Title 2"] and reason(r).split("\n")[-1] == "2 rulings or questions over RECALL_ADMIT_MAX were not checked.", (calls, reason(r)[-120:])) -r, calls, ms = run(hook(five), RECALL_ADMIT_MAX="1", RECALL_BUDGET="900") -check("R8 RECALL_ADMIT_MAX=1 checks one, counts four, and the whole reason fits RECALL_BUDGET", - len(calls) == 1 and reason(r).endswith("4 rulings or questions over RECALL_ADMIT_MAX were not checked.") and len(reason(r)) <= 900, len(reason(r))) +r, calls, ms = run(hook(five), RECALL_ADMIT_MAX="1", RECALL_BUDGET="560") +check("R8 RECALL_ADMIT_MAX=1 checks one, counts four, and the whole reason, trimmed to fit, stays within RECALL_BUDGET", + len(calls) == 1 and reason(r).endswith("4 rulings or questions over RECALL_ADMIT_MAX were not checked.") and len(reason(r)) <= 560 + and len(reason(r).split("\n")) == 3, len(reason(r))) +r, calls, ms = run(hook(five), items=[item("r3", "An unchecked batch member")] + NB) +check("R8 a ruling in the batch that was not checked is still never listed as a neighbour", held(r) and "t:ruling:r3" not in reason(r), reason(r)[:300]) r, calls, ms = run(hook(five[:3])) check("R8 three rulings are all checked and nothing is counted unchecked", len(calls) == 3 and "RECALL_ADMIT_MAX" not in reason(r).split("\n")[-1]) @@ -976,7 +978,7 @@ def failcase(label, kind, expect_calls, setup=None, env=None, **kw): check("R9 %s: a note naming %s, no decision, nothing recorded" % (label, kind), ok, (r.stdout[:200], r.stderr[:100], len(calls))) check("R9 %s: no byte of the input appears" % label, CANARY.encode() not in r.stdout + r.stderr) return hh -failcase("Unavailable", "transport", 1, env={"FAKE_MODE": "unavailable"}) +failcase("Unavailable", "tool", 1, env={"FAKE_MODE": "unavailable"}) failcase("an unparsable answer", "answer", 1, env={"FAKE_MODE": "garbage"}) failcase("a binding that dies", "transport", 1, env={"FAKE_MODE": "die"}) failcase("no binding", "binding", 0, env={"HOME": T + "/nohome", "USERPROFILE": T + "/nohome"}) @@ -989,7 +991,7 @@ try: failcase("an unwritable store (the deny is not printed before the record)", "store", 1, setup=dangling) except OSError: check("R9 an unwritable store (symlinks unavailable here)", True) -hh = failcase("Unavailable", "transport", 1, env={"FAKE_MODE": "unavailable"}) +hh = failcase("Unavailable", "tool", 1, env={"FAKE_MODE": "unavailable"}) r, calls, ms = run(hh) check("R9 after a failed check the same batch is still held on its first real check", held(r))