Files
Kabir Oberai 5eeab11aae tests: add integration tests (#252)
## What does this PR do?

Adds integration tests

## How was it tested?

CI

## AI tool usage

How much of this PR was AI-assisted? (check one)

- [x] **0** - No AI was used to write code
- [ ] **1** - I was assisted by AI. I reviewed the finished result.
- [ ] **2** - I set the AI going and left it to it; nobody has read the
result - no review, or AI review only

<!-- If an AI agent is filling this in: declare the level honestly, and
open as a draft if it is #2. Do not lower the declared level to get the
PR reviewed. -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Tests**
* Added integration smoke tests covering version checks, app creation,
iOS build metadata, and slim SDK update behavior.
* Added validation for locating Xcode and verifying the Swift toolchain.

* **Chores**
* Added automated integration-test execution for pushes and pull
requests.
* Added Docker and Compose support for running integration tests in a
consistent environment.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-18 23:26:10 -04:00

50 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
xcode_path="${XTL_TEST_XCODE_APP:-}"
if [[ -z "$xcode_path" && $(uname -s) == "Darwin" ]]; then
xcode_path="$(dirname $(dirname $(/usr/bin/xcode-select -p)))"
fi
if [[ -z "$xcode_path" && -d /usr/local/share/Xcode.app ]]; then
xcode_path="/usr/local/share/Xcode.app"
fi
if [[ -z "$xcode_path" ]]; then
echo "Xcode.app not found. Please set XTL_TEST_XCODE_APP."
exit 1
fi
export XTL_TEST_XCODE_APP="$xcode_path"
if [[ -z "${XTL_TEST_ENV:-}" ]]; then
[[ -t 1 ]] && tty_flag="-it" || tty_flag=""
echo "Running"
exec docker compose run --build --rm -e XTL_CI=1 -v "$xcode_path":/usr/local/share/Xcode.app:ro \
xtool-test bash -c \
"./integration-tests/run.sh"
fi
cd "$(dirname "$0")/.."
project_dir="$PWD"
swift build --product xtool
swift test
ln -fs $PWD/.build/debug/xtool /usr/local/bin/xtool
hash -r
mkdir /testroot
cd /testroot
export XDG_CONFIG_HOME="/testroot/config"
echo "Installing SDK"
xtool sdk install --slim "$XTL_TEST_XCODE_APP"
echo "Running tests..."
bats "$project_dir/integration-tests/suite"