| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #!/bin/sh
- # Run the Statum markdown test suites.
- #
- # Builds the vendored QuickJS interpreter if no `qjs` is on PATH, then runs
- # the hand-written regression suite and the CommonMark spec conformance
- # suite. Exits non-zero when regressions fail or the spec score drops below
- # the target rate.
- #
- # Usage: tests/markdown/run.sh [-v] (-v lists every failing spec example)
- set -e
- cd "$(dirname "$0")/../.."
- ROOT=$(pwd)
- QJS="$ROOT/tools/qjs/qjs"
- TARGET=95
- if ! command -v qjs >/dev/null 2>&1; then
- echo "== building vendored QuickJS =="
- "$ROOT/tools/qjs/build.sh"
- else
- QJS=$(command -v qjs)
- fi
- echo "== regressions =="
- "$QJS" "$ROOT/tests/markdown/regressions.js"
- echo ""
- echo "== CommonMark 0.31.2 spec =="
- # -v (or any second argument) makes spec-test.js print each failing example
- "$QJS" "$ROOT/tests/markdown/spec-test.js" "${1:-}"
- # spec-test.js prints "TOTAL <pass>/<total> <rate>%"; re-derive the rate from
- # a quiet rerun so the gate below cannot be fooled by the verbose listing.
- SCORE=$("$QJS" "$ROOT/tests/markdown/spec-test.js" | grep '^ TOTAL' | sed 's/.* \([0-9.]*\)%$/\1/')
- echo ""
- echo "spec score: ${SCORE}% (target ${TARGET}%)"
- # compare as integers to avoid depending on awk float handling
- PASSING=$(echo "$SCORE" | cut -d. -f1)
- if [ "$PASSING" -lt "$TARGET" ]; then
- echo "FAIL: spec conformance ${SCORE}% is below the ${TARGET}% target"
- exit 1
- fi
- echo "OK"
|