xtool.git
Publicgit clone https://git.maproj.org/xtool.gitxtool.git / integration-tests / run.sh
run.sh49 lines · 1.1 KiBRaw
| 1 | #!/bin/bash |
| 2 | |
| 3 | set -euo pipefail |
| 4 | |
| 5 | xcode_path="${XTL_TEST_XCODE_APP:-}" |
| 6 | |
| 7 | if [[ -z "$xcode_path" && $(uname -s) == "Darwin" ]]; then |
| 8 | xcode_path="$(dirname $(dirname $(/usr/bin/xcode-select -p)))" |
| 9 | fi |
| 10 | |
| 11 | if [[ -z "$xcode_path" && -d /usr/local/share/Xcode.app ]]; then |
| 12 | xcode_path="/usr/local/share/Xcode.app" |
| 13 | fi |
| 14 | |
| 15 | if [[ -z "$xcode_path" ]]; then |
| 16 | echo "Xcode.app not found. Please set XTL_TEST_XCODE_APP." |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | export XTL_TEST_XCODE_APP="$xcode_path" |
| 21 | |
| 22 | if [[ -z "${XTL_TEST_ENV:-}" ]]; then |
| 23 | [[ -t 1 ]] && tty_flag="-it" || tty_flag="" |
| 24 | |
| 25 | echo "Running" |
| 26 | |
| 27 | exec docker compose run --build --rm -e XTL_CI=1 -v "$xcode_path":/usr/local/share/Xcode.app:ro \ |
| 28 | xtool-test bash -c \ |
| 29 | "./integration-tests/run.sh" |
| 30 | fi |
| 31 | |
| 32 | cd "$(dirname "$0")/.." |
| 33 | |
| 34 | project_dir="$PWD" |
| 35 | |
| 36 | swift build --product xtool |
| 37 | swift test |
| 38 | ln -fs $PWD/.build/debug/xtool /usr/local/bin/xtool |
| 39 | hash -r |
| 40 | |
| 41 | mkdir /testroot |
| 42 | cd /testroot |
| 43 | export XDG_CONFIG_HOME="/testroot/config" |
| 44 | |
| 45 | echo "Installing SDK" |
| 46 | xtool sdk install --slim "$XTL_TEST_XCODE_APP" |
| 47 | |
| 48 | echo "Running tests..." |
| 49 | bats "$project_dir/integration-tests/suite" |