File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,6 +103,11 @@ done
103103echo " $proof_files " | grep -E ' \.lean$' | while read -r f; do
104104 [ -z " $f " ] && continue
105105 grep -nE ' \bsorry\b|^[[:space:]]*axiom[[:space:]]' " $f " 2> /dev/null | while IFS=: read -r ln rest; do
106+ # Strip string literals to avoid false positives (e.g. from keyword tables or debug strings)
107+ rest_no_strings=" $( echo " $rest " | sed ' s/"[^"]*"//g' ) "
108+ if ! echo " $rest_no_strings " | grep -qE ' \bsorry\b|^[[:space:]]*axiom[[:space:]]' ; then
109+ continue
110+ fi
106111 emit_marker " $f " " $ln " " lean-sorry-or-axiom" " $( echo " $rest " | head -c 80) "
107112 done
108113done
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # SPDX-License-Identifier: MPL-2.0
3+
4+ set -euo pipefail
5+
6+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
7+ CHECK_SCRIPT=" ${SCRIPT_DIR} /../scripts/check-trusted-base.sh"
8+
9+ TEST_DIR=$( mktemp -d)
10+ trap ' rm -rf "$TEST_DIR"' EXIT
11+
12+ echo " Running check-trusted-base.sh tests..."
13+
14+ # Test 1: Should ignore 'sorry' in string literals
15+ cat << 'EOF ' > "${TEST_DIR}/string_literal.lean"
16+ def my_keywords : List String := ["sorry", "axiom"]
17+ EOF
18+
19+ # Provide an empty proof-debt file to satisfy the script's basic requirements
20+ mkdir -p " ${TEST_DIR} /docs"
21+ touch " ${TEST_DIR} /docs/proof-debt.md"
22+
23+ if " ${CHECK_SCRIPT} " " ${TEST_DIR} " > /dev/null; then
24+ echo " PASS: Ignored 'sorry' in string literals."
25+ else
26+ echo " FAIL: Matched 'sorry' in string literals incorrectly."
27+ exit 1
28+ fi
29+
30+ # Test 2: Should flag actual 'sorry'
31+ cat << 'EOF ' > "${TEST_DIR}/actual_sorry.lean"
32+ theorem fermat : a ^ n + b ^ n = c ^ n := by
33+ sorry
34+ EOF
35+
36+ if " ${CHECK_SCRIPT} " " ${TEST_DIR} " > /dev/null; then
37+ echo " FAIL: Failed to flag actual 'sorry'."
38+ exit 1
39+ else
40+ echo " PASS: Flagged actual 'sorry'."
41+ fi
42+
43+ echo " All tests passed!"
You can’t perform that action at this time.
0 commit comments