|
@@ -43,4 +43,62 @@ fi
|
|
|
echo "compiletest built (p1_rc=$p1, phase 1 rc=1 is the expected rollup)"
|
|
echo "compiletest built (p1_rc=$p1, phase 1 rc=1 is the expected rollup)"
|
|
|
|
|
|
|
|
FX=${1:-tests/fixtures}
|
|
FX=${1:-tests/fixtures}
|
|
|
-ls "$FX"/*.pas 2>/dev/null | ./compiletest
|
|
|
|
|
|
|
+
|
|
|
|
|
+# ---- assert against tests/fixtures/expected.tsv ---------------------------
|
|
|
|
|
+# Previously this script only printed a verdict, so "17 of 23" was a number a
|
|
|
|
|
+# human counted by hand and a wrong error POSITION was invisible. Both the
|
|
|
|
|
+# verdict and the numbers are compared now, and the exit status is meaningful.
|
|
|
|
|
+EXP="$FX/expected.tsv"
|
|
|
|
|
+if [ ! -f "$EXP" ]; then
|
|
|
|
|
+ echo "no expectations file $EXP - printing only"
|
|
|
|
|
+ ls "$FX"/*.pas 2>/dev/null | ./compiletest
|
|
|
|
|
+ exit 0
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+RAW=$(mktemp) || exit 9
|
|
|
|
|
+ls "$FX"/*.pas 2>/dev/null | ./compiletest > "$RAW"
|
|
|
|
|
+
|
|
|
|
|
+# expected row for a fixture basename, normalised to single spaces
|
|
|
|
|
+# (only rows that actually carry a verdict count, so the wrapped comment
|
|
|
|
|
+# lines in expected.tsv can never be mistaken for data)
|
|
|
|
|
+expect_for() {
|
|
|
|
|
+ awk -F'\t' -v n="$1" '
|
|
|
|
|
+ ($2 == "OK" || $2 == "ERR") && $1 == n {
|
|
|
|
|
+ out = ""
|
|
|
|
|
+ for (i = 2; i <= NF; i++)
|
|
|
|
|
+ out = (out == "") ? $i : out " " $i
|
|
|
|
|
+ print out
|
|
|
|
|
+ exit
|
|
|
|
|
+ }
|
|
|
|
|
+ ' "$EXP"
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+pass=0; fail=0
|
|
|
|
|
+while IFS= read -r base; do
|
|
|
|
|
+ actual=$(grep -F "$base" "$RAW" \
|
|
|
|
|
+ | head -1 \
|
|
|
|
|
+ | tr -d '\r' \
|
|
|
|
|
+ | sed -E 's/^[^ ]+[[:space:]]+//' \
|
|
|
|
|
+ | tr -s ' ' \
|
|
|
|
|
+ | sed -E 's/^OK code=([0-9]+) data=([0-9]+)$/OK \1 \2/;
|
|
|
|
|
+ s/^ERROR ([0-9]+) at pos ([0-9]+)$/ERR \1 \2/')
|
|
|
|
|
+ want=$(expect_for "$base" | tr -s ' ')
|
|
|
|
|
+ if [ -z "$want" ]; then
|
|
|
|
|
+ printf ' %-24s NO_EXPECTATION got: %s\n' "$base" "$actual"
|
|
|
|
|
+ fail=$((fail + 1))
|
|
|
|
|
+ elif [ "$actual" = "$want" ]; then
|
|
|
|
|
+ printf ' %-24s PASS %s\n' "$base" "$actual"
|
|
|
|
|
+ pass=$((pass + 1))
|
|
|
|
|
+ else
|
|
|
|
|
+ printf ' %-24s FAIL\n expected: %s\n actual: %s\n' \
|
|
|
|
|
+ "$base" "$want" "$actual"
|
|
|
|
|
+ fail=$((fail + 1))
|
|
|
|
|
+ fi
|
|
|
|
|
+done <<EOF
|
|
|
|
|
+$(ls "$FX"/*.pas 2>/dev/null | xargs -n1 basename | sed 's/\.pas$//')
|
|
|
|
|
+EOF
|
|
|
|
|
+
|
|
|
|
|
+echo "----------------------------------------------------------------"
|
|
|
|
|
+echo "compile matrix: $pass passed, $fail failed (of $((pass + fail)))"
|
|
|
|
|
+rm -f "$RAW"
|
|
|
|
|
+[ "$fail" -eq 0 ] || exit 1
|