From 7aded8e61fe570b69f23b8d8b2102c55271f3fe2 Mon Sep 17 00:00:00 2001 From: Tobi Lutke Date: Wed, 11 Mar 2026 07:17:01 -0400 Subject: [PATCH] add auto/bench.sh: unit tests + liquid-spec + perf benchmark --- auto/bench.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 auto/bench.sh diff --git a/auto/bench.sh b/auto/bench.sh new file mode 100755 index 00000000..77fc4809 --- /dev/null +++ b/auto/bench.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Auto-research benchmark script for Liquid +# Runs: unit tests → liquid-spec → performance benchmark +# Outputs machine-readable metrics on success +# Exit code 0 = all good, non-zero = broken +set -euo pipefail + +cd "$(dirname "$0")/.." + +# ── Step 1: Unit tests (fast gate) ────────────────────────────────── +echo "=== Unit Tests ===" +if ! bundle exec rake base_test 2>&1; then + echo "FATAL: unit tests failed" + exit 1 +fi + +# ── Step 2: liquid-spec (correctness gate) ────────────────────────── +echo "" +echo "=== Liquid Spec ===" +SPEC_OUTPUT=$(bundle exec liquid-spec run spec/ruby_liquid.rb 2>&1 || true) +echo "$SPEC_OUTPUT" | tail -3 + +# Extract failure count from "Total: N passed, N failed, N errors" line +# Allow known pre-existing failures (≤2) +TOTAL_LINE=$(echo "$SPEC_OUTPUT" | grep "^Total:" || echo "Total: 0 passed, 0 failed, 0 errors") +FAILURES=$(echo "$TOTAL_LINE" | sed -n 's/.*\([0-9][0-9]*\) failed.*/\1/p') +ERRORS=$(echo "$TOTAL_LINE" | sed -n 's/.*\([0-9][0-9]*\) error.*/\1/p') +FAILURES=${FAILURES:-0} +ERRORS=${ERRORS:-0} +TOTAL_BAD=$((FAILURES + ERRORS)) + +if [ "$TOTAL_BAD" -gt 2 ]; then + echo "FATAL: liquid-spec has $FAILURES failures and $ERRORS errors (threshold: 2)" + exit 1 +fi + +# ── Step 3: Performance benchmark ────────────────────────────────── +echo "" +echo "=== Performance Benchmark ===" +bundle exec ruby performance/bench_quick.rb 2>&1