Skip to content

Commit f874a83

Browse files
committed
Set exit code 65 if xcodebuild test has unexpected failures
1 parent 27f48af commit f874a83

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

scripts/build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function RunXcodebuild() {
114114

115115
result=0
116116
xcodebuild "$@" | tee xcodebuild.log | "${xcbeautify_cmd[@]}" || result=$?
117+
result=$(CheckUnexpectedFailures $result xcodebuild.log)
117118

118119
if [[ $result == 65 ]]; then
119120
ExportLogs "$@"
@@ -123,6 +124,7 @@ function RunXcodebuild() {
123124

124125
result=0
125126
xcodebuild "$@" | tee xcodebuild.log | "${xcbeautify_cmd[@]}" || result=$?
127+
result=$(CheckUnexpectedFailures $result xcodebuild.log)
126128
fi
127129

128130
if [[ $result != 0 ]]; then
@@ -138,6 +140,19 @@ function ExportLogs() {
138140
python "${scripts_dir}/xcresult_logs.py" "$@"
139141
}
140142

143+
function CheckUnexpectedFailures() {
144+
local result=$1
145+
local log_file=$2
146+
147+
if [[ $result != 0 ]]; then
148+
return "$result"
149+
elif grep -Eq "[1-9]\d* failures \([1-9]\d* unexpected\)" "$log_file"; then
150+
return 65
151+
else
152+
return 0
153+
fi
154+
}
155+
141156
if [[ "$xcode_major" -lt 15 ]]; then
142157
ios_flags=(
143158
-sdk 'iphonesimulator'

0 commit comments

Comments
 (0)