#!/usr/bin/env bash # Proves the test runner detects each kind of failure, using deliberate fixtures. set -uo pipefail cd "$(dirname "${BASH_SOURCE[0]}")/.." status=0 # check check() { local fixture="$1" expected="$2" needle="$3" output code output="$(tools/run_tests.sh "--root=res://test/fixtures/$fixture" 2>&1)" code=$? if [[ "$code" -ne "$expected" ]]; then echo "selfcheck FAIL $fixture: exit $code, expected $expected" echo "$output" | tail -n 20 status=1 elif ! grep -qF -- "$needle" <<<"$output"; then echo "selfcheck FAIL $fixture: output lacks '$needle'" echo "$output" | tail -n 20 status=1 else echo "selfcheck ok $fixture (exit $code)" fi } check passes 0 "Tests: 3 passed, 0 failed." check assert 1 "deliberate fixture failure: expected 3, got 2" check script_error 1 "engine error:" check engine_error 1 "engine error:" check parse_error 1 "could not compile the script" check not_a_test 1 "does not extend TestCase" check missing_error 1 "expected an engine error containing" check empty 1 "No tests ran" exit "$status"