Repository Public
1#!/usr/bin/env bash2# Author: Simon-Pierre Boucher — contact@spboucher.ai3# File: Scripts/t.sh4# Description: Runs `swift test` with an optional filter and a time limit, printing only verdict lines.5#6# Usage: Scripts/t.sh [filter] [seconds] [lines] (integration tests need Scripts/backend-dev.sh start)7cd "$(dirname "$0")/.."8LIMIT="${2:-300}"; LOG=/tmp/spdrive-test.log9perl -e 'alarm shift; exec @ARGV' "$LIMIT" swift test ${1:+--filter "$1"} > "$LOG" 2>&110STATUS=$?11if [ $STATUS -eq 142 ]; then echo "TIMEOUT after ${LIMIT}s" >> "$LOG"; fi12sed 's/\x1b\[[0-9;]*m//g' "$LOG" | grep -E "error|failed|Executed .* tests|TIMEOUT|Fatal|passed \(" | grep -vE "Test Suite|^error: Process|SwiftCompile|' passed" | sed -E "s#$PWD/##" | cut -c1-400 | awk '!seen[$0]++' | tail -${3:-40}13exit $STATUS14