#!/bin/sh
# script/test: run the test suite.
set -eu

ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"

main() {
    cd "$ROOT"
    echo "Running tests..."
    timeout 30 yarn run test 2>&1 || {
        echo "--- Rerunning with --verbose for details ---"
        timeout 30 yarn run test:verbose 2>&1 || true
        # Always fail: the first run already proved the tests are broken, so a
        # flaky pass on the rerun must not turn the build green.
        exit 1
    }
}

main "$@"
