Skip to content

Commit 2ede9ba

Browse files
committed
tech: Improve build_test script
1 parent 87af8f2 commit 2ede9ba

File tree

1 file changed

+55
-3
lines changed

1 file changed

+55
-3
lines changed

Support/build_test

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,61 @@ SOURCE_DIR="${BASH_SOURCE[0]%/*}"
2525
source "$SOURCE_DIR/utils.sh"
2626

2727
# Properties
28-
SCHEME=${SCHEME:-"PactSwiftMockServer-macOS"}
29-
DESTINATION=${DESTINATION:-"arch=$(uname -m)"}
3028
DERIVED_DATA_PATH=".build/DerivedData"
29+
DESTINATIONS=()
30+
SCHEMES=()
31+
32+
###############
33+
# "private"
34+
35+
function __buildTestHelp {
36+
echo -e "Builds sheme on destinations and runs tests
37+
38+
Usage:
39+
build_test [--scheme VAL1 --target VAL2]
40+
41+
Note:
42+
Must be provided as pairs with --scheme argument first of the two!
43+
44+
Options:
45+
--scheme Scheme to build and run tests for
46+
--target Target to build for and test with
47+
"
48+
}
49+
50+
SCHEME_TARGET_PAIRS=()
51+
52+
if [ $# -eq 0 ]; then
53+
# CI is setup with a matrix defining SCHEME and DESTINATION env vars
54+
SCHEME="${SCHEME:-"PactSwiftMockServer-macOS"}"
55+
DEFAULT_DESTINATION="arch=$(uname -m)"
56+
DESTINATION="${DESTINATION:-$DEFAULT_DESTINATION}"
57+
58+
SCHEME_TARGET_PAIRS=("$SCHEME:::$DESTINATION")
59+
60+
else
61+
while [ $# -gt 0 ]; do
62+
case "$1" in
63+
--scheme)
64+
SCHEME_TARGET_PAIRS+=("$2:::$4")
65+
shift 4
66+
;;
67+
68+
-h|--help)
69+
__buildTestHelp
70+
exit
71+
;;
72+
73+
*)
74+
echo -e "***************************\n* Error: Invalid argument.*\n***************************\n"
75+
exit 1
76+
esac
77+
done
78+
fi
3179

3280
# Run tests
33-
executeCommand "xcodebuild clean test -project \"PactSwiftMockServer.xcodeproj\" -scheme \"$SCHEME\" -destination \"$DESTINATION\" -enableCodeCoverage YES -derivedDataPath \"$DERIVED_DATA_PATH\" GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES | xcbeautify"
81+
for INDEX in "${SCHEME_TARGET_PAIRS[@]}"; do
82+
SCHEME="${INDEX%%:::*}"
83+
TARGET="${INDEX##*::}"
84+
executeCommand "xcodebuild clean test -project \"PactSwiftMockServer.xcodeproj\" -scheme \"$SCHEME\" -destination \"$TARGET\" -enableCodeCoverage YES -derivedDataPath \"$DERIVED_DATA_PATH\" GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES | xcbeautify"
85+
done

0 commit comments

Comments
 (0)