Skip to content

Commit 7907e3a

Browse files
committed
docs(verify): a doctor control, the lock file named, and a dependency project
Section D reads a clean store first, then requires the finding's label and the seeded lock file's name, and after --fix requires the reinstalled payload: no seeded file and */mcpp.toml present. Section C2 emits the build database of section B's project: the dependency's set, no watched store path, the S1 SHOULD fields, and an unchanged tree with target/ present. Sections that need python3 say so when it is missing. Refs #636
1 parent 653eb1f commit 7907e3a

1 file changed

Lines changed: 53 additions & 5 deletions

File tree

.agents/docs/2026-09-14-636-verify.sh

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ printf 'module hello.greet;\nstd::string greet() { return "hi"; }\n' > "$d/src/g
8989
printf 'import hello.greet;\nimport std;\nint main() { std::println("{}", greet()); }\n' > "$d/src/main.cpp"
9090
printf 'int main() { return 0; }\n' > "$d/tests/test_smoke.cpp"
9191
before=$(cd "$d" && find . -type f | sort | xargs sha256sum | sha256sum)
92-
if (cd "$d" && "$STORE" emit build-database --format json > "$root/c.json" 2> "$root/c.err"); then
92+
if ! command -v python3 >/dev/null 2>&1; then
93+
skip "C: no python3 in the sandbox to read the document"
94+
elif (cd "$d" && "$STORE" emit build-database --format json > "$root/c.json" 2> "$root/c.err"); then
9395
after=$(cd "$d" && find . -type f | sort | xargs sha256sum | sha256sum)
9496
[ "$before" = "$after" ] && ok "the project tree is unchanged" || fail "the project tree changed"
9597
if python3 - "$root/c.json" <<'EOF'
@@ -112,14 +114,60 @@ else
112114
fail "emit build-database failed"; tail -5 "$root/c.err"
113115
fi
114116

117+
section "C2. the build database of a project with an mcpp-index dependency"
118+
d=$root/b
119+
if [ ! -f "$d/mcpp.toml" ] || ! command -v python3 >/dev/null 2>&1; then
120+
skip "C2: section B's project or python3 is missing"
121+
else
122+
before=$(cd "$d" && find . -type f | sort | xargs sha256sum | sha256sum)
123+
if (cd "$d" && "$STORE" emit build-database --format json > "$root/c2.json" 2> "$root/c2.err"); then
124+
after=$(cd "$d" && find . -type f | sort | xargs sha256sum | sha256sum)
125+
[ "$before" = "$after" ] && ok "the built project's tree is unchanged, target/ included" || fail "the built project's tree changed"
126+
if python3 - "$root/c2.json" "$REG" <<'EOF'
127+
import json, os, sys
128+
e = json.load(open(sys.argv[1])); reg = os.path.realpath(sys.argv[2])
129+
db, watch = e["data"]["database"], e["data"]["watch"]
130+
sets = {s["name"]: s for s in db["sets"]}
131+
assert {"eco636", "mcpplibs.cmdline", "mcpp:std"} <= set(sets), sorted(sets)
132+
assert all(not os.path.realpath(w).startswith(reg) for w in watch if os.path.isabs(w)), watch
133+
for tid, t in db["ide"]["toolchains"].items():
134+
assert all(os.path.isfile(f) for f in t["config-files"]), (tid, t["config-files"])
135+
for s in db["sets"]:
136+
for u in s["translation-units"]:
137+
head = [u["arguments"][0]] + s["baseline-arguments"] + u["local-arguments"]
138+
assert u["arguments"][:len(head)] == head and u["private"] is False, (s["name"], u["source"])
139+
print("sets", sorted(sets), "watch", len(watch))
140+
EOF
141+
then ok "the document has the dependency's set, watches no store path, and carries the S1 SHOULD fields"
142+
else fail "the dependency project's document"; fi
143+
else
144+
fail "emit build-database failed on the dependency project"; tail -5 "$root/c2.err"
145+
fi
146+
fi
147+
115148
section "D. xlings reports and repairs a payload that holds another package's download"
116149
cmd=$(find "$REG/data/xpkgs" -maxdepth 2 -path '*cmdline*' -type d | tail -1)
150+
strip_ansi() { sed 's/\x1b\[[0-9;]*[A-Za-z]//g'; }
117151
if [ -n "$cmd" ]; then
152+
# The control: the store section B produced has no finding of this kind.
153+
XLINGS_HOME="$REG" "$REG/bin/xlings" self doctor 2>&1 | strip_ansi > "$root/doctor0.log"
154+
grep -qi 'swept payload' "$root/doctor0.log" && { fail "self doctor reports a swept payload before any was seeded"; grep -i -A2 'swept' "$root/doctor0.log" | head -6; } || ok "the fresh store has no swept-payload finding"
155+
# The downloader's shape: an archive beside its zero-length lock.
118156
printf 'x' > "$cmd/intruder-1.0-linux-x86_64.tar.gz"; : > "$cmd/intruder-1.0-linux-x86_64.tar.gz.lock"
119-
XLINGS_HOME="$REG" "$REG/bin/xlings" self doctor > "$root/doctor.log" 2>&1
120-
grep -qi 'intruder\|swept\|download' "$root/doctor.log" && ok "self doctor reports the swept payload" || { fail "self doctor did not report it"; tail -8 "$root/doctor.log"; }
121-
XLINGS_HOME="$REG" "$REG/bin/xlings" self doctor --fix > "$root/fix.log" 2>&1
122-
[ ! -e "$cmd/intruder-1.0-linux-x86_64.tar.gz.lock" ] && ok "self doctor --fix leaves no download sidecar in the payload" || { fail "the sidecar is still there after --fix"; tail -8 "$root/fix.log"; }
157+
XLINGS_HOME="$REG" "$REG/bin/xlings" self doctor 2>&1 | strip_ansi > "$root/doctor.log"
158+
if grep -qi 'swept payload' "$root/doctor.log" && grep -qF "intruder-1.0-linux-x86_64.tar.gz.lock" "$root/doctor.log"; then
159+
ok "self doctor reports the swept payload and names the lock file"
160+
else
161+
fail "self doctor did not report the seeded payload"; tail -12 "$root/doctor.log"
162+
fi
163+
XLINGS_HOME="$REG" "$REG/bin/xlings" self doctor --fix 2>&1 | strip_ansi > "$root/fix.log"
164+
cmd=$(find "$REG/data/xpkgs" -maxdepth 2 -path '*cmdline*' -type d | tail -1)
165+
if [ -n "$cmd" ] && [ ! -e "$cmd/intruder-1.0-linux-x86_64.tar.gz.lock" ] && [ ! -e "$cmd/intruder-1.0-linux-x86_64.tar.gz" ] \
166+
&& [ -n "$(find "$cmd" -mindepth 2 -maxdepth 2 -name mcpp.toml)" ]; then
167+
ok "self doctor --fix reinstalls the payload: no seeded file, and */mcpp.toml is back"
168+
else
169+
fail "the payload after --fix"; ls -A "$cmd" 2>/dev/null | head; tail -12 "$root/fix.log"
170+
fi
123171
else
124172
skip "D: section B produced no cmdline payload to seed"
125173
fi

0 commit comments

Comments
 (0)