Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0a8308a

Browse files
author
Chris Yang
authored
Upload xcresults to LUCI cloud storage (#41647)
Taking over from #41644 fixes: flutter/flutter#125823 Steps to verify [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 00f20fb commit 0a8308a

File tree

2 files changed

+76
-20
lines changed

2 files changed

+76
-20
lines changed

testing/run_tests.py

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import multiprocessing
1818
import os
1919
import re
20+
import shutil
2021
import subprocess
2122
import sys
2223
import tempfile
@@ -753,21 +754,43 @@ def run_objc_tests(ios_variant='ios_debug_sim_unopt', test_filter=None):
753754
ios_unit_test_dir = os.path.join(
754755
BUILDROOT_DIR, 'flutter', 'testing', 'ios', 'IosUnitTests'
755756
)
756-
# Avoid using xcpretty unless the following can be addressed:
757-
# - Make sure all relevant failure output is printed on a failure.
758-
# - Make sure that a failing exit code is set for CI.
759-
# See https://github.com/flutter/flutter/issues/63742
760-
test_command = [
761-
'xcodebuild '
762-
'-sdk iphonesimulator '
763-
'-scheme IosUnitTests '
764-
"-destination name='" + new_simulator_name + "' "
765-
'test '
766-
'FLUTTER_ENGINE=' + ios_variant
767-
]
768-
if test_filter is not None:
769-
test_command[0] = test_command[0] + ' -only-testing:%s' % test_filter
770-
run_cmd(test_command, cwd=ios_unit_test_dir, shell=True)
757+
758+
with tempfile.TemporaryDirectory(suffix='ios_embedding_xcresult'
759+
) as result_bundle_temp:
760+
result_bundle_path = os.path.join(result_bundle_temp, 'ios_embedding')
761+
762+
# Avoid using xcpretty unless the following can be addressed:
763+
# - Make sure all relevant failure output is printed on a failure.
764+
# - Make sure that a failing exit code is set for CI.
765+
# See https://github.com/flutter/flutter/issues/63742
766+
test_command = [
767+
'xcodebuild '
768+
'-sdk iphonesimulator '
769+
'-scheme IosUnitTests '
770+
'-resultBundlePath ' + result_bundle_path + ' '
771+
'-destination name=' + new_simulator_name + ' '
772+
'test '
773+
'FLUTTER_ENGINE=' + ios_variant
774+
]
775+
if test_filter is not None:
776+
test_command[0] = test_command[0] + ' -only-testing:%s' % test_filter
777+
run_cmd(test_command, cwd=ios_unit_test_dir, shell=True)
778+
779+
# except:
780+
# The LUCI environment may provide a variable containing a directory path
781+
# for additional output files that will be uploaded to cloud storage.
782+
# Upload the xcresult when the tests fail.
783+
luci_test_outputs_path = os.environ.get('FLUTTER_TEST_OUTPUTS_DIR')
784+
xcresult_bundle = os.path.join(
785+
result_bundle_temp, 'ios_embedding.xcresult'
786+
)
787+
if luci_test_outputs_path and os.path.exists(xcresult_bundle):
788+
dump_path = os.path.join(
789+
luci_test_outputs_path, 'ios_embedding.xcresult'
790+
)
791+
# xcresults contain many little files. Archive the bundle before upload.
792+
shutil.make_archive(dump_path, 'zip', root_dir=xcresult_bundle)
793+
771794
finally:
772795
delete_simulator(new_simulator_name)
773796

testing/scenario_app/run_ios_tests.sh

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,58 @@ fi
4141
# Can also be set via Simulator app Device > Rotate Device Automatically
4242
defaults write com.apple.iphonesimulator RotateWindowWhenSignaledByGuest -int 1
4343

44-
cd $SRC_DIR/out/$FLUTTER_ENGINE/scenario_app/Scenarios
44+
SCENARIO_PATH=$SRC_DIR/out/$FLUTTER_ENGINE/scenario_app/Scenarios
45+
pushd .
46+
cd $SCENARIO_PATH
47+
48+
RESULT_BUNDLE_FOLDER="ios_scenario_xcresult"
49+
RESULT_BUNDLE_PATH="${SCENARIO_PATH}/${RESULT_BUNDLE_FOLDER}"
50+
51+
# Zip and upload xcresult to luci.
52+
# First parameter ($1) is the zip output name.
53+
zip_and_upload_xcresult_to_luci () {
54+
# We don't want the zip to contain the abusolute path,
55+
# so use relative path (./$RESULT_BUNDLE_FOLDER) instead.
56+
zip -q -r $1 "./$RESULT_BUNDLE_FOLDER"
57+
mv -f $1 $FLUTTER_TEST_OUTPUTS_DIR
58+
exit 1
59+
}
4560

4661
echo "Running simulator tests with Skia"
4762
echo ""
4863

49-
set -o pipefail && xcodebuild -sdk iphonesimulator \
64+
mktemp -d $RESULT_BUNDLE_PATH
65+
66+
if set -o pipefail && xcodebuild -sdk iphonesimulator \
5067
-scheme Scenarios \
68+
-resultBundlePath "$RESULT_BUNDLE_PATH/ios_scenario.xcresult" \
5169
-destination 'platform=iOS Simulator,OS=16.2,name=iPhone SE (3rd generation)' \
5270
clean test \
53-
FLUTTER_ENGINE="$FLUTTER_ENGINE"
71+
FLUTTER_ENGINE="$FLUTTER_ENGINE"; then
72+
echo "test success."
73+
else
74+
echo "test failed."
75+
zip_and_upload_xcresult_to_luci "ios_scenario_xcresult.zip"
76+
fi
77+
rm -rf $RESULT_BUNDLE_PATH
5478

5579
echo "Running simulator tests with Impeller"
5680
echo ""
5781

5882
# Skip testFontRenderingWhenSuppliedWithBogusFont: https://github.com/flutter/flutter/issues/113250
59-
set -o pipefail && xcodebuild -sdk iphonesimulator \
83+
if set -o pipefail && xcodebuild -sdk iphonesimulator \
6084
-scheme Scenarios \
85+
-resultBundlePath "$RESULT_BUNDLE_PATH/ios_scenario.xcresult" \
6186
-destination 'platform=iOS Simulator,OS=16.2,name=iPhone SE (3rd generation)' \
6287
clean test \
6388
FLUTTER_ENGINE="$FLUTTER_ENGINE" \
6489
-skip-testing "ScenariosUITests/BogusFontTextTest/testFontRenderingWhenSuppliedWithBogusFont" \
65-
INFOPLIST_FILE="Scenarios/Info_Impeller.plist" # Plist with FLTEnableImpeller=YES
90+
INFOPLIST_FILE="Scenarios/Info_Impeller.plist"; then # Plist with FLTEnableImpeller=YES
91+
echo "test success."
92+
else
93+
echo "test failed."
94+
zip_and_upload_xcresult_to_luci "ios_scenario_impeller_xcresult.zip"
95+
fi
96+
rm -rf $RESULT_BUNDLE_PATH
97+
98+
popd

0 commit comments

Comments
 (0)