Name the rules, say when there is nothing to say, and hold a baseline
Four things SplitLint wanted, and they build on each other. EVERY WARNING NAMES ITS RULE, in brackets at the end the way a compiler names the flag that produced it. Twelve rules, listed by --help. That makes the other three possible: suppressions can name one rule and leave the line honest about the others, the harness can assert on a rule's identity rather than on the wording of its message, and --machine can print one tab separated line per warning - file, line, rule, message, help - so nothing downstream reads prose. This file's own output was parsed with regular expressions three times in one day before it had a shape to rely on. A CLEAN RUN SAYS SO: No style warnings: 121 files checked against 12 rules. It used to exit in silence, which does not tell you it found nothing - it tells you nothing at all, and from outside the two are identical. A MARKER THAT SILENCES NOTHING IS ITSELF REPORTED, as dead-suppression. An exception that outlived whatever made it necessary is the thing the required reason exists to prevent, and naming the wrong rule now gets you both the warning you meant to silence and a note that your suppression is doing nothing. AND THE CORPUS IS HELD TO A BASELINE. Sixty one warnings are left in it deliberately and nothing stopped a sixty second. Tests/lint-baseline.txt records how many of each rule each file should produce, so a new one fails make test while the sixty one stay quiet; confirmed by adding an INIA 0d0 to Say.asm and watching it name the file, the rule and the count. It counts per file and rule rather than recording line numbers, because line numbers would churn the whole baseline whenever anything was inserted above a warning - the same reason cycle counts are stripped from recorded output here. ./Tests/lint.sh --bless records it again. One thing to know for next time: the rule name was inserted before the line number at all twenty one call sites, and the signature was changed to match rather than the twenty one call sites being fixed. (path, rule, line) reads no worse than (path, line, rule) and one edit has fewer ways to go wrong than twenty one.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
Programs/CosmOS/Apps/Copy.asm redundant-setd 2
|
||||
Programs/CosmOS/Apps/Edit.asm redundant-setd 3
|
||||
Programs/CosmOS/Apps/Wander.asm redundant-setd 1
|
||||
Programs/CosmOS/Assembler/Asm.asm redundant-assignment 2
|
||||
Programs/CosmOS/Assembler/Asm.asm redundant-setd 8
|
||||
Programs/CosmOS/Assembler/classify.asm redundant-assignment 2
|
||||
Programs/CosmOS/Assembler/classify.asm redundant-setd 6
|
||||
Programs/CosmOS/Assembler/readTest.asm redundant-setd 1
|
||||
Programs/CosmOS/Assembler/token.asm redundant-assignment 4
|
||||
Programs/CosmOS/Assembler/token.asm redundant-setd 2
|
||||
Programs/CosmOS/Assembler/tokenTest.asm redundant-setd 1
|
||||
Programs/CosmOS/Source/cosmos.asm redundant-assignment 1
|
||||
Programs/CosmOS/Source/cosmos.asm redundant-setd 9
|
||||
Programs/CosmOS/Source/sbfs.asm branch-to-next 1
|
||||
Programs/CosmOS/Source/sbfs.asm redundant-assignment 4
|
||||
Programs/CosmOS/Source/sbfs.asm redundant-setd 1
|
||||
Programs/CosmOS/Source/text.asm redundant-setd 2
|
||||
Programs/Loader/loader.asm redundant-assignment 1
|
||||
Programs/testPrograms/branchTest.asm redundant-assignment 1
|
||||
Programs/testPrograms/branchTest.asm redundant-ccf 1
|
||||
Programs/testPrograms/controllerWriteTest.asm branch-to-next 1
|
||||
Programs/testPrograms/diagnostics/duplicateLabel.asm branch-to-next 1
|
||||
Programs/testPrograms/diskTest.asm redundant-assignment 1
|
||||
Programs/testPrograms/dispatchTest.asm branch-to-next 1
|
||||
Programs/testPrograms/fenceTest.asm redundant-assignment 1
|
||||
Programs/testPrograms/moveQTest.asm redundant-ccf 1
|
||||
Programs/testPrograms/rawCallAndOffsets.asm redundant-assignment 1
|
||||
Programs/testPrograms/waitTest.asm redundant-assignment 1
|
||||
@@ -21,6 +21,16 @@ cd "$ROOT" || exit 1
|
||||
LINT="$ROOT/SplitLint"
|
||||
[ -x "$LINT" ] || { echo "SplitLint is not built."; exit 1; }
|
||||
|
||||
# Recording the corpus as it stands, for when warnings have been deliberately fixed or
|
||||
# deliberately accepted. Same shape as run.sh's --bless, and for the same reason.
|
||||
if [ "${1:-}" = "--bless" ]; then
|
||||
"$LINT" --machine $(find Programs -name '*.asm' | sort) \
|
||||
| awk -F'\t' '{print $1"\t"$3}' | sort | uniq -c \
|
||||
| awk '{printf "%s\t%s\t%s\n", $2, $3, $1}' | sort > "$ROOT/Tests/lint-baseline.txt"
|
||||
echo "Recorded $(wc -l < "$ROOT/Tests/lint-baseline.txt" | tr -d ' ') file and rule pairs."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir -p Tests/build
|
||||
fixture=Tests/build/lint.asm
|
||||
output=Tests/build/lint.out
|
||||
@@ -234,6 +244,35 @@ else
|
||||
printf " [%sFAIL%s] and does not fail on a suppressed one\n" "$RED" "$RESET"
|
||||
fi
|
||||
|
||||
# ---- And the corpus has not grown a new warning ----
|
||||
#
|
||||
# Sixty one warnings are left in the corpus ON PURPOSE - registers whose equal values mean
|
||||
# different things, idioms whose redundancy is what makes them self contained, arms of
|
||||
# comparison chains that get reordered. Nothing stopped a sixty second from appearing.
|
||||
#
|
||||
# THE BASELINE IS COUNTS PER FILE AND RULE RATHER THAN LINE NUMBERS. Recording lines would
|
||||
# churn the whole file every time something was inserted above a warning, which is the same
|
||||
# reason a cycle count is stripped from every recorded output here.
|
||||
baseline="$ROOT/Tests/lint-baseline.txt"
|
||||
current=Tests/build/lint-current.txt
|
||||
"$LINT" --machine $(find Programs -name '*.asm' | sort) \
|
||||
| awk -F'\t' '{print $1"\t"$3}' | sort | uniq -c \
|
||||
| awk '{printf "%s\t%s\t%s\n", $2, $3, $1}' | sort > "$current"
|
||||
|
||||
if [ ! -f "$baseline" ]; then
|
||||
FAIL=$((FAIL + 1)); MISSING+=("the baseline is missing")
|
||||
printf " [%sFAIL%s] the corpus baseline is missing\n" "$RED" "$RESET"
|
||||
elif diff -q "$baseline" "$current" >/dev/null; then
|
||||
PASS=$((PASS + 1))
|
||||
printf " [%sok %s] the corpus matches its baseline %s file and rule pairs\n" \
|
||||
"$GREEN" "$RESET" "$(wc -l < "$current" | tr -d ' ')"
|
||||
else
|
||||
FAIL=$((FAIL + 1)); MISSING+=("the corpus baseline")
|
||||
printf " [%sFAIL%s] the corpus has moved away from its baseline\n" "$RED" "$RESET"
|
||||
diff "$baseline" "$current" | sed 's/^/ /'
|
||||
printf " To accept these, run: ./Tests/lint.sh --bless\n"
|
||||
fi
|
||||
|
||||
echo
|
||||
if [ "$FAIL" -eq 0 ]; then
|
||||
echo "All $PASS SplitLint checks passed."
|
||||
|
||||
Reference in New Issue
Block a user