Repository Public
1#!/usr/bin/env bash2# SP Lecture Studio3# File: scripts/test-all.sh4# Description: Runs the automated tests: package unit + integration tests, optional 90-minute export, optional UI tests on the simulators.5# usage: scripts/test-all.sh [--long] [--ui] [--ui-mac]6#7# Author: Simon-Pierre Boucher8# Contact: contact@spboucher.ai9set -uo pipefail10cd "$(dirname "$0")/.."11LOGS="$PWD/build/logs"; mkdir -p "$LOGS"12long=0; ui=0; uimac=013for a in "$@"; do case "$a" in --long) long=1 ;; --ui) ui=1 ;; --ui-mac) uimac=1 ;; esac; done14fail=015summary() { grep -E "Executed [0-9]+ tests?" "$1" | tail -1 | sed 's/^[[:space:]]*//'; grep -E "error: -\[" "$1" | sort -u | cut -c1-240 | head -20; grep -E "^MEASURE" "$1" | sort -u; }16echo "== Package tests (unit + integration) =="17if [[ $long == 1 ]]; then LECTURE_LONG_TESTS=1 swift test >"$LOGS/test-packages.log" 2>&1 || fail=1; else swift test >"$LOGS/test-packages.log" 2>&1 || fail=1; fi18grep -E "Test Suite '(UnitTests|IntegrationTests)\.xctest' (passed|failed)" "$LOGS/test-packages.log" | sed 's/ at .*//'19summary "$LOGS/test-packages.log"20if [[ $ui == 1 ]]; then21 for device in iphone ipad; do echo "== UI tests: $device =="; scripts/test-ui.sh "$device" || fail=1; done22fi23if [[ $uimac == 1 ]]; then echo "== UI tests: mac (takes over the pointer; the screen must be unlocked) =="; scripts/test-ui.sh mac || fail=1; fi24[[ $fail == 0 ]] && echo "ALL PASSED" || echo "SOME TESTS FAILED"25exit $fail26