-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4562 from wix/new-xcuitest-build
build(ios): new XCUITest runner build.
- Loading branch information
Showing
1 changed file
with
64 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,71 @@ | ||
#!/bin/bash -e | ||
#!/usr/bin/env bash | ||
|
||
XCODEPROJ=$1 | ||
XCUITEST_OUTPUT_DIR=$2 | ||
CONFIGURATION=Release | ||
PROJECT_NAME=DetoxXCUITestRunner | ||
set -euo pipefail | ||
|
||
# Clean up the output directory | ||
CONFIGURATION="Release" | ||
PROJECT_NAME="DetoxXCUITestRunner" | ||
|
||
rm -fr "${XCUITEST_OUTPUT_DIR}" | ||
print_usage() { | ||
echo "Usage: $0 <xcodeproj_path> <xcuitest_output_dir>" | ||
exit 1 | ||
} | ||
|
||
# Make sure the output directory exists | ||
setup_output_dir() { | ||
local output_dir="$1" | ||
rm -rf "${output_dir}" | ||
mkdir -p "${output_dir}" | ||
} | ||
|
||
mkdir -p "${XCUITEST_OUTPUT_DIR}" | ||
create_temp_dir() { | ||
local temp_dir | ||
temp_dir=$(mktemp -d) | ||
echo "${temp_dir}" | ||
} | ||
|
||
# Build Simulator version | ||
build_for_simulator() { | ||
local xcodeproj="$1" | ||
local temp_dir="$2" | ||
|
||
env -i bash -c "xcodebuild -project \"${XCODEPROJ}\" -scheme \"${PROJECT_NAME}\" -UseNewBuildSystem=\"YES\" -configuration \"${CONFIGURATION}\" -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' -derivedDataPath \"${XCUITEST_OUTPUT_DIR}\" build-for-testing -quiet" | ||
env -i xcodebuild \ | ||
-project "${xcodeproj}" \ | ||
-scheme "${PROJECT_NAME}" \ | ||
-UseNewBuildSystem="YES" \ | ||
-configuration "${CONFIGURATION}" \ | ||
-sdk iphonesimulator \ | ||
-destination 'generic/platform=iOS Simulator' \ | ||
-derivedDataPath "${temp_dir}" \ | ||
build-for-testing \ | ||
-quiet | ||
} | ||
|
||
process_xctestrun() { | ||
local temp_dir="$1" | ||
local output_dir="$2" | ||
|
||
local xctestrun_file | ||
xctestrun_file=$(find "${temp_dir}" -name "*.xctestrun") | ||
|
||
# Copy the parent directory of the .xctestrun file, which contains the .xctestrun file and its associated binaries | ||
cp -r "$(dirname "${xctestrun_file}")" "${output_dir}" | ||
} | ||
|
||
main() { | ||
if [ $# -ne 2 ]; then | ||
print_usage | ||
fi | ||
|
||
local xcodeproj="$1" | ||
local output_dir="$2" | ||
|
||
setup_output_dir "${output_dir}" | ||
local temp_dir | ||
temp_dir=$(create_temp_dir) | ||
|
||
# Ensure cleanup happens on script exit | ||
trap "[[ -d ${temp_dir} ]] && rm -rf ${temp_dir}" EXIT | ||
|
||
build_for_simulator "${xcodeproj}" "${temp_dir}" | ||
process_xctestrun "${temp_dir}" "${output_dir}" | ||
} | ||
|
||
main "$@" |