diff --git a/tests/fixtures/review-loop-run/annotated-table-cell.md b/tests/fixtures/review-loop-run/annotated-table-cell.md new file mode 100644 index 0000000..c5bbe9a --- /dev/null +++ b/tests/fixtures/review-loop-run/annotated-table-cell.md @@ -0,0 +1,10 @@ +# Review + +## Count by severity + +| Severity | Count | +|----------|-------| +| CRITICAL | 0 | +| HIGH | 1 (H-R3-1: gate bypass) | +| MEDIUM | 2 (M-1, M-2) | +| LOW | 0 | diff --git a/tests/fixtures/review-loop-run/declaration-with-annotation.md b/tests/fixtures/review-loop-run/declaration-with-annotation.md new file mode 100644 index 0000000..a9f3f1f --- /dev/null +++ b/tests/fixtures/review-loop-run/declaration-with-annotation.md @@ -0,0 +1,5 @@ +# Review + +## Count by severity + +- HIGH: 1 (H-R3-1) diff --git a/tests/fixtures/review-loop-run/prose-historic-quote.md b/tests/fixtures/review-loop-run/prose-historic-quote.md new file mode 100644 index 0000000..8af8043 --- /dev/null +++ b/tests/fixtures/review-loop-run/prose-historic-quote.md @@ -0,0 +1,12 @@ +# Review + +## Count by severity + +| Severity | Count | +|----------|-------| +| CRITICAL | 0 | +| HIGH | 2 | +| MEDIUM | 0 | +| LOW | 0 | + +Note: the earlier bug reported MEDIUM=404 seen on 2026-09-13. diff --git a/tests/fixtures/review-loop-run/suspect-derived-lower.md b/tests/fixtures/review-loop-run/suspect-derived-lower.md new file mode 100644 index 0000000..314b3c3 --- /dev/null +++ b/tests/fixtures/review-loop-run/suspect-derived-lower.md @@ -0,0 +1,9 @@ +# Review + +## critical + +There is a serious problem described here, but this section does not +follow the declaration-line or table conventions the parser expects, +so no severity value can be extracted from it. + +Further prose continues without any line starting with a severity word. diff --git a/tests/fixtures/review-loop-run/suspect-derived.md b/tests/fixtures/review-loop-run/suspect-derived.md new file mode 100644 index 0000000..f2f53a6 --- /dev/null +++ b/tests/fixtures/review-loop-run/suspect-derived.md @@ -0,0 +1,9 @@ +# Review + +## CRITICAL + +There is a serious problem described here, but this section does not +follow the declaration-line or table conventions the parser expects, +so no severity value can be extracted from it. + +Further prose continues without any line starting with a severity word. diff --git a/tests/test-review-loop-run.sh b/tests/test-review-loop-run.sh index 2d7d9c4..0435a59 100755 --- a/tests/test-review-loop-run.sh +++ b/tests/test-review-loop-run.sh @@ -80,6 +80,36 @@ assert_exit "no count block derives, exits 4" 4 "$rc" assert_contains "no count block counts" "CRITICAL=1 HIGH=2 MEDIUM=0 LOW=0" "$out" assert_contains "no count block marked derived" "(derived)" "$out" +echo "review-loop-run — counts (CR-7/CR-8/CR-9, bug 5352fe72)" +if [[ "${CR789_IMPL_READY:-0}" != "1" ]]; then + echo " SKIP CR-7/CR-8/CR-9 counts tests (set CR789_IMPL_READY=1 once implemented)" +else + out=$("$SCRIPT" counts "$FIXTURES/annotated-table-cell.md"); rc=$? + assert_contains "counts annotated table cell" "CRITICAL=0 HIGH=1 MEDIUM=2 LOW=0" "$out" + out=$("$SCRIPT" counts "$FIXTURES/annotated-table-cell.md"); rc=$? + assert_exit "counts annotated cell exits 4" 4 "$rc" + + out=$("$SCRIPT" counts "$FIXTURES/prose-historic-quote.md"); rc=$? + assert_contains "counts prose historic quote ignored" "CRITICAL=0 HIGH=2 MEDIUM=0 LOW=0" "$out" + assert_exit "counts prose historic quote ignored exit 4" 4 "$rc" + + out=$("$SCRIPT" counts "$FIXTURES/suspect-derived.md"); rc=$? + assert_contains "counts suspect derived zero marks suspect" "CRITICAL=0 HIGH=0 MEDIUM=0 LOW=0 (suspect)" "$out" + # companion handle (not in spec matrix): asserts the negative -- no (derived) marker on a suspect result + [[ "$out" == *"(derived)"* ]] && { printf " ${RED}FAIL${NC} %s\n unexpected: (derived) present\n" "counts suspect derived zero not marked derived"; FAIL=$((FAIL+1)); } || { printf " ${GREEN}PASS${NC} %s\n" "counts suspect derived zero not marked derived"; PASS=$((PASS+1)); } + out=$("$SCRIPT" counts "$FIXTURES/suspect-derived.md"); rc=$? + assert_exit "counts suspect derived zero exits 4" 4 "$rc" + + out=$("$SCRIPT" counts "$FIXTURES/suspect-derived-lower.md"); rc=$? + assert_contains "counts suspect derived zero case insensitive" "CRITICAL=0 HIGH=0 MEDIUM=0 LOW=0 (suspect)" "$out" + assert_exit "counts suspect derived zero case insensitive exit 4" 4 "$rc" + + out=$("$SCRIPT" counts "$FIXTURES/declaration-with-annotation.md"); rc=$? + assert_contains "counts declaration line annotation rejected" "CRITICAL=0 HIGH=0 MEDIUM=0 LOW=0 (derived)" "$out" + # companion handle (not in spec matrix): exit-code check for the same declaration-line-annotation-rejected case + assert_exit "counts declaration line annotation rejected exits 0" 0 "$rc" +fi + echo "review-loop-run — status" printf 'x\nexit=0\n' > "$REVIEW_LOOP_RUN_DIR/t-r1-stdout.txt" out=$("$SCRIPT" status --name t 2>&1); rc=$?