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]7cd "$(dirname "$0")/.."8LIMIT="${2:-120}"; LOG=/tmp/spmusic-test.log9# perl's alarm ends the run at the deadline (no background watchdog to race with).10perl -e 'alarm shift; exec @ARGV' "$LIMIT" swift test ${1:+--filter "$1"} > "$LOG" 2>&111STATUS=$?12if [ $STATUS -eq 142 ]; then echo "TIMEOUT after ${LIMIT}s" >> "$LOG"; pkill -x xctest; fi13sed 's/\x1b\[[0-9;]*m//g' "$LOG" | grep -E "error|passed \(|failed \(|Executed .* tests|TIMEOUT|Fatal" | grep -vE "Test Suite|^error: Process|SwiftCompile" | cut -c1-360 | awk '!seen[$0]++' | tail -${3:-30}14exit $STATUS15