fix(execute): the helper and the executor give red proof no list
Operator decisions 30 and 31 (14.10); review findings 11ee78c5 and d01df508. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
73e53f3134
commit
a70f082f6e
6 changed files with 224 additions and 43 deletions
|
|
@ -17,6 +17,17 @@
|
|||
# 6. lib/verification/red-proof.mjs with --plan/--step and a --tests that
|
||||
# differs from the plan's list (exit 2, tests-mismatch).
|
||||
# 7. artifact-commit with an empty-model trailer (exit 1, HEAD unchanged).
|
||||
# 8. plan-validator on a 1.9 plan whose Files entry wraps onto a line that
|
||||
# opens with a backticked flag (exit 0, no PLAN_STEP_PATH_NOT_A_PATH).
|
||||
# 9. plan-validator on a 1.9 plan whose Test first File line wraps onto a
|
||||
# line that opens with the source path (exit 0, no PLAN_STEP_TESTS_ONLY).
|
||||
# 10. red-proof --red-only with --plan/--step and no --tests in a second temp
|
||||
# repo (exit 0; its JSON tests field is the plan's one test file).
|
||||
# 11. the same with a plan path that does not exist (exit 2, plan-unreadable).
|
||||
# 12. the same as 10 in text form with a --tests that differs (exit 2, the
|
||||
# line " plan_tests: tests/parser.test.mjs").
|
||||
# 13. red-proof --red-only on a 1.8 plan whose File line names two tests,
|
||||
# each with a (new) note (exit 0; tests is both, in order; decision 31).
|
||||
# Prints "e2e: ok" and exits 0, or names the failed check and exits 1.
|
||||
# bash 3.2 compatible, ASCII only.
|
||||
|
||||
|
|
@ -157,5 +168,94 @@ rc=$?
|
|||
after="$(git -C "$REPO" rev-parse HEAD)"
|
||||
[ "$before" = "$after" ] || fail "artifact-commit with an empty-model trailer: HEAD moved from $before to $after"
|
||||
|
||||
# ---- 8. to 13. decisions 29 to 31: wrapped 1.9 lines, red proof without --tests ----
|
||||
|
||||
node --input-type=module -e '
|
||||
import { writeFileSync } from "node:fs";
|
||||
import { buildPlan } from "./tests/helpers/plan-v18-builder.mjs";
|
||||
const dir = process.argv[1];
|
||||
const e2e = { endToEnd: "bash tests/e2e.sh" };
|
||||
writeFileSync(dir + "/p8.md", buildPlan({ version: "1.9", steps: [{
|
||||
filesRaw: "`src/a.mjs`\n `--strict` flag added",
|
||||
}, e2e] }));
|
||||
writeFileSync(dir + "/p9.md", buildPlan({ version: "1.9", steps: [{
|
||||
file: "src/parser.mjs", test: "tests/parser.test.mjs",
|
||||
filesRaw: "`src/parser.mjs`, `tests/parser.test.mjs`",
|
||||
testFirstRaw: " - File: `tests/parser.test.mjs`\n `src/parser.mjs` is the module it drives",
|
||||
}, e2e] }));
|
||||
writeFileSync(dir + "/p13.md", buildPlan({ steps: [{
|
||||
file: "src/parser.mjs",
|
||||
filesRaw: "`src/parser.mjs`, `tests/a.test.mjs`, `tests/b.test.mjs`",
|
||||
testFirstRaw: " - File: `tests/a.test.mjs` (new), `tests/b.test.mjs` (new)",
|
||||
}, e2e] }));
|
||||
' "$TMP" || fail "could not write the plans for checks 8 to 13"
|
||||
|
||||
out="$(node lib/validators/plan-validator.mjs --strict --json "$TMP/p8.md" 2>&1)"
|
||||
rc=$?
|
||||
[ "$rc" -eq 0 ] || fail "8: 1.9 plan with a wrapped Files entry: plan-validator exit $rc, expected 0: $out"
|
||||
if echo "$out" | grep -q 'PLAN_STEP_PATH_NOT_A_PATH'; then
|
||||
fail "8: 1.9 plan with a wrapped Files entry: PLAN_STEP_PATH_NOT_A_PATH in: $out"
|
||||
fi
|
||||
|
||||
out="$(node lib/validators/plan-validator.mjs --strict --json "$TMP/p9.md" 2>&1)"
|
||||
rc=$?
|
||||
[ "$rc" -eq 0 ] || fail "9: 1.9 plan with a wrapped Test first File line: plan-validator exit $rc, expected 0: $out"
|
||||
if echo "$out" | grep -q 'PLAN_STEP_TESTS_ONLY'; then
|
||||
fail "9: 1.9 plan with a wrapped Test first File line: PLAN_STEP_TESTS_ONLY in: $out"
|
||||
fi
|
||||
|
||||
R="$TMP/repo-red"
|
||||
mkdir -p "$R/src" "$R/tests" || fail "mkdir $R"
|
||||
git -C "$R" init -q || fail "git init (second repo)"
|
||||
git -C "$R" config user.name 'E2E Test'
|
||||
git -C "$R" config user.email 'test@example.invalid'
|
||||
git -C "$R" config commit.gpgsign false
|
||||
git -C "$R" config core.hooksPath "$TMP/hooks-none"
|
||||
echo 'x' > "$R/README.md"
|
||||
git -C "$R" add README.md && git -C "$R" commit -q -m 'init' || fail "initial commit in the second temp repo"
|
||||
echo 'export const parse = (s) => Number(s);' > "$R/src/parser.mjs"
|
||||
for t in parser a b; do
|
||||
cat > "$R/tests/$t.test.mjs" <<'EOT'
|
||||
import { test } from 'node:test';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import { parse } from '../src/parser.mjs';
|
||||
test('parse reads a number', () => { assert.equal(parse('2'), 2); });
|
||||
EOT
|
||||
done
|
||||
|
||||
# tests_equal <json file> <expected JSON array>: exit 0 when the JSON's tests deep-equals it.
|
||||
tests_equal() {
|
||||
node -e '
|
||||
const assert = require("node:assert");
|
||||
const fs = require("node:fs");
|
||||
const r = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
|
||||
try { assert.deepStrictEqual(r.tests, JSON.parse(process.argv[2])); } catch (e) { process.exit(1); }
|
||||
' "$1" "$2"
|
||||
}
|
||||
|
||||
node lib/verification/red-proof.mjs --red-only --cwd "$R" --base HEAD --cmd 'node --test tests/parser.test.mjs' --plan "$TMP/p9.md" --step 1 --json >"$TMP/rp10.json" 2>"$TMP/rp10.err"
|
||||
rc=$?
|
||||
[ "$rc" -eq 0 ] || fail "10: red-proof with --plan/--step and no --tests: exit $rc, expected 0: $(cat "$TMP/rp10.json" "$TMP/rp10.err")"
|
||||
tests_equal "$TMP/rp10.json" '["tests/parser.test.mjs"]' \
|
||||
|| fail "10: red-proof tests is not [\"tests/parser.test.mjs\"]: $(cat "$TMP/rp10.json")"
|
||||
|
||||
out="$(node lib/verification/red-proof.mjs --red-only --cwd "$R" --base HEAD --cmd 'node --test tests/parser.test.mjs' --plan "$TMP/nope.md" --step 1 --json 2>&1)"
|
||||
rc=$?
|
||||
[ "$rc" -eq 2 ] || fail "11: red-proof with a plan that does not exist: exit $rc, expected 2: $out"
|
||||
echo "$out" | grep -q 'plan-unreadable' \
|
||||
|| fail "11: red-proof with a plan that does not exist: no plan-unreadable in: $out"
|
||||
|
||||
out="$(node lib/verification/red-proof.mjs --red-only --cwd "$R" --base HEAD --cmd 'node --test tests/parser.test.mjs' --tests tests/a.test.mjs --plan "$TMP/p9.md" --step 1 2>&1)"
|
||||
rc=$?
|
||||
[ "$rc" -eq 2 ] || fail "12: red-proof with a --tests that differs (text): exit $rc, expected 2: $out"
|
||||
echo "$out" | grep -Fqx ' plan_tests: tests/parser.test.mjs' \
|
||||
|| fail "12: red-proof with a --tests that differs (text): no line ' plan_tests: tests/parser.test.mjs' in: $out"
|
||||
|
||||
node lib/verification/red-proof.mjs --red-only --cwd "$R" --base HEAD --cmd 'node --test tests/a.test.mjs tests/b.test.mjs' --plan "$TMP/p13.md" --step 1 --json >"$TMP/rp13.json" 2>"$TMP/rp13.err"
|
||||
rc=$?
|
||||
[ "$rc" -eq 0 ] || fail "13: red-proof on a 1.8 plan with two (new) tests: exit $rc, expected 0: $(cat "$TMP/rp13.json" "$TMP/rp13.err")"
|
||||
tests_equal "$TMP/rp13.json" '["tests/a.test.mjs","tests/b.test.mjs"]' \
|
||||
|| fail "13: red-proof tests is not the two test paths in order: $(cat "$TMP/rp13.json")"
|
||||
|
||||
echo 'e2e: ok'
|
||||
exit 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue