Skip to content

Commit

Permalink
[Infra] Add check for unexpected test failures in build.sh (#14144)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard authored Nov 20, 2024
1 parent 380a861 commit db77a77
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions FirebasePerformance/Tests/Unit/Timer/FPRCounterListTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ + (void)setUp {
[super setUp];
FIRPerformance *performance = [FIRPerformance sharedInstance];
[performance setDataCollectionEnabled:YES];
#ifdef UNSWIZZLE_AVAILABLE
[[FPRClient sharedInstance] disableInstrumentation];
#endif // UNSWIZZLE_AVAILABLE
}

+ (void)tearDown {
[super tearDown];
FIRPerformance *performance = [FIRPerformance sharedInstance];
[performance setDataCollectionEnabled:NO];
#ifdef UNSWIZZLE_AVAILABLE
[[FPRClient sharedInstance] disableInstrumentation];
#endif // UNSWIZZLE_AVAILABLE
}

/** Validates counterlist object creation. */
Expand Down
19 changes: 16 additions & 3 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ source scripts/check_secrets.sh
function RunXcodebuild() {
echo xcodebuild "$@"

xcbeautify_cmd=(xcbeautify --renderer github-actions)
xcbeautify_cmd=(xcbeautify --renderer github-actions --disable-logging)

result=0
xcodebuild "$@" | tee xcodebuild.log | "${xcbeautify_cmd[@]}" || result=$?
xcodebuild "$@" | tee xcodebuild.log | "${xcbeautify_cmd[@]}" \
&& CheckUnexpectedFailures xcodebuild.log \
|| result=$?

if [[ $result == 65 ]]; then
ExportLogs "$@"
Expand All @@ -122,7 +124,9 @@ function RunXcodebuild() {
sleep 5

result=0
xcodebuild "$@" | tee xcodebuild.log | "${xcbeautify_cmd[@]}" || result=$?
xcodebuild "$@" | tee xcodebuild.log | "${xcbeautify_cmd[@]}" \
&& CheckUnexpectedFailures xcodebuild.log \
|| result=$?
fi

if [[ $result != 0 ]]; then
Expand All @@ -138,6 +142,15 @@ function ExportLogs() {
python "${scripts_dir}/xcresult_logs.py" "$@"
}

function CheckUnexpectedFailures() {
local log_file=$1

if grep -Eq "[1-9]\d* failures \([1-9]\d* unexpected\)" "$log_file"; then
echo "xcodebuild failed with unexpected failures." 1>&2
return 65
fi
}

if [[ "$xcode_major" -lt 15 ]]; then
ios_flags=(
-sdk 'iphonesimulator'
Expand Down

0 comments on commit db77a77

Please sign in to comment.