context-pack tests: pin the --only reserve and charge, the cut-window budget, header base, missing base
Targets the mutants that survived the first fix run: need arithmetic of cut and full windows, the reserve for the not-expanded line at the budget edge, the left-reserve >= 4 threshold with two windows, the exact more-lines note, the blank line after the table, a non-sha base never echoed in the header, and a spec without a base refused rather than crashing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
dbcb41a046
commit
5bf88b80cb
1 changed files with 27 additions and 1 deletions
|
|
@ -388,7 +388,7 @@ R2=$T/cp2; mkdir -p "$R2/src/[a]" "$R2/src/a"; R2w=$(wp "$R2")
|
|||
g2() { git -C "$R2" -c user.name=t -c user.email=t@t -c core.autocrlf=false "$@" >/dev/null 2>&1; }
|
||||
g2 init -q
|
||||
seqf x 30 >"$R2/src/[a]/f.txt"; seqf x 30 >"$R2/src/a/f.txt"
|
||||
for n in s t u v; do seqf x 30 >"$R2/$n.txt"; done; seqf w 12 >"$R2/w.txt"
|
||||
for n in s t u v; do seqf x 30 >"$R2/$n.txt"; done; seqf w 12 >"$R2/w.txt"; seqf g 200 >"$R2/big.txt"; echo q1 >"$R2/one.txt"
|
||||
g2 add -A; g2 commit -q -m base; B2=$(git -C "$R2" rev-parse HEAD)
|
||||
{ printf 'new1\nnew2\n'; cat "$R2/src/a/f.txt"; } >"$R2/src/a/f.new"; mv "$R2/src/a/f.new" "$R2/src/a/f.txt"
|
||||
sed -i 8,12d "$R2/s.txt"; sed -i 15,25d "$R2/t.txt"
|
||||
|
|
@ -460,10 +460,18 @@ while read -r nm fld; do
|
|||
grep -qF "context-pack: spec: $fld: InvalidInput; --spec-json reads a saved view" "$T/cp.err" && echo "ok context-pack names $fld" || { echo "FAIL context-pack message for $nm: $(cat "$T/cp.err")"; fail=1; }
|
||||
cnot "wrong-typed spec $nm: no value" "CANARY"; cnot "wrong-typed spec $nm: no traceback" "Traceback"
|
||||
done <"$T/cp-bad.list"
|
||||
echo '{"base": "CANARY-base", "deletes": [], "file_changes": [{"change": "c", "location": {"path": "a.txt", "line": 1, "end_line": 2}}]}' >"$T/cp-specnb.json"
|
||||
r=$(cpo --spec-json "$(wp "$T/cp-specnb.json")"); cchk "a base that is no sha" 3 "$r"
|
||||
cin "a base that is no sha reads UNRESOLVED" "UNRESOLVED base not a commit here"
|
||||
cin "a base that is no sha is not echoed in the header" "base unresolvable HEAD"
|
||||
echo '{"file_changes": [{"change": "c", "location": {"path": "a.txt", "line": 1}}]}' >"$T/cp-spec-nobase.json"
|
||||
r=$(cpo --spec-json "$(wp "$T/cp-spec-nobase.json")"); cchk "a spec value without a base" 4 "$r"
|
||||
grep -qF "context-pack: spec: not a cut_spec value; --spec-json reads a saved view" "$T/cp.err" && echo "ok context-pack a missing base is a typed refusal" || { echo "FAIL context-pack missing base: $(cat "$T/cp.err")"; fail=1; }
|
||||
# a --max-lines below the table: the table always lists every anchor and no window prints
|
||||
r=$(cpo --spec-json "$(wp "$T/cp-spec30.json")" --max-lines 5); cchk "--max-lines below the table" 0 "$r"
|
||||
[ "$(grep -c '^\[' "$T/cp.out")" = 30 ] && echo "ok context-pack a small budget keeps the full table" || { echo "FAIL context-pack small budget table"; fail=1; }
|
||||
cnot "a small budget prints no window" "== ["
|
||||
[ -z "$(sed -n 32p "$T/cp.out")" ] && echo "ok context-pack a blank line follows the table" || { echo "FAIL context-pack blank line after the table"; fail=1; }
|
||||
cin "a small budget lists every window as not expanded" "not expanded: --only 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30"
|
||||
# --only truncates a window to the budget and says how to see the rest
|
||||
r=$(cpo --spec-json "$S1" --only 1 --max-lines 50); cchk "--only truncation" 0 "$r"
|
||||
|
|
@ -480,6 +488,24 @@ echo '{"base": "'$BASE'", "deletes": [], "file_changes": [
|
|||
r=$(cpo --spec-json "$(wp "$T/cp-spec2w.json")" --only 1,2 --max-lines 50); cchk "--only two windows" 0 "$r"
|
||||
[ "$(wc -l <"$T/cp.out" | tr -d ' ')" = 50 ] && echo "ok context-pack --only keeps room for the not-expanded line" || { echo "FAIL context-pack --only reserve: $(wc -l <"$T/cp.out")"; fail=1; }
|
||||
cin "--only: the window that no longer fits is listed" "not expanded: --only 2"
|
||||
r=$(cpo --spec-json "$(wp "$T/cp-spec2w.json")" --only 1,2 --max-lines 161); cchk "--only first window needs exactly the remaining budget" 0 "$r"
|
||||
cin "--only: a window that fills the budget minus the reserve is cut, not skipped" "== [1] big.txt:20-169"
|
||||
[ "$(wc -l <"$T/cp.out" | tr -d ' ')" = 161 ] && echo "ok context-pack --only cut window keeps the reserve line" || { echo "FAIL context-pack --only exact need: $(wc -l <"$T/cp.out")"; fail=1; }
|
||||
r=$(cpo --spec-json "$(wp "$T/cp-spec2w.json")" --only 1,2 --max-lines 8); cchk "--only two windows, too small to cut" 0 "$r"
|
||||
cnot "--only: below four lines after the reserve nothing is cut" "== ["
|
||||
cin "--only: both are listed as not expanded" "not expanded: --only 1,2"
|
||||
echo '{"base": "'$B2'", "deletes": [], "file_changes": [
|
||||
{"change": "long", "location": {"path": "big.txt", "line": 20, "end_line": 169}},
|
||||
{"change": "tiny", "location": {"path": "one.txt", "line": 1, "end_line": 1}}]}' >"$T/cp-spec3.json"
|
||||
r=$(cp2 --spec-json "$(wp "$T/cp-spec3.json")" --only 1,2 --max-lines 100); cchk "--only cut window then a tiny one" 0 "$r"
|
||||
[ "$(wc -l <"$T/cp.out" | tr -d ' ')" = 100 ] && echo "ok context-pack a cut window is charged what it prints" || { echo "FAIL context-pack cut window charge: $(wc -l <"$T/cp.out")"; fail=1; }
|
||||
cin "a cut window leaves no room for the next one" "not expanded: --only 2"
|
||||
r=$(cpo --spec-json "$S1" --max-lines 104); cin "a 100-line cut window needs 102 lines of budget" "not expanded: --only 1"
|
||||
r=$(cpo --spec-json "$S1" --max-lines 105); cin "a 100-line cut window fits in 105 lines" "56 more lines: --only 1 --max-lines 160"
|
||||
[ "$(wc -l <"$T/cp.out" | tr -d ' ')" = 105 ] && echo "ok context-pack a 100-line cut window fills 105 lines" || { echo "FAIL context-pack cut window at 105: $(wc -l <"$T/cp.out")"; fail=1; }
|
||||
grep -qxF "56 more lines: --only 1 --max-lines 160" "$T/cp.out" && echo "ok context-pack the more-lines note is its own line" || { echo "FAIL context-pack more-lines note line"; fail=1; }
|
||||
r=$(cpo --spec-json "$(wp "$T/cp-spec30.json")" --max-lines 202); cchk "reserve line at the budget edge" 0 "$r"
|
||||
[ "$(grep -c '^== \[' "$T/cp.out")" = 9 ] && [ "$(wc -l <"$T/cp.out" | tr -d ' ')" -le 202 ] && echo "ok context-pack a window that would crowd out the not-expanded line is skipped" || { echo "FAIL context-pack reserve at 202: $(wc -l <"$T/cp.out")"; fail=1; }
|
||||
# the binding env block reaches the server; the caller environment overrides it
|
||||
mcp env -u HUGINN_ENDPOINT -u EUREKA_INSTANCE FAKE_MODE=needenv FAKE_NEED=rudp://binding $PY "$CP" t:cut_spec:cut-x.r1 "$Rw" >"$T/cp.out" 2>"$T/cp.err"; r=$?
|
||||
cchk "env from the binding reaches the server" 3 "$r"; cmp -s "$T/cp.out" "$T/cp.want" && echo "ok context-pack binding env supplies the server environment" || { echo "FAIL context-pack binding env not applied"; fail=1; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue