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

Commit 233fc22

Browse files
jmagmanChris Yang
authored andcommitted
Upload xcresults to LUCI cloud storage
upload scenario app test result fix script
1 parent 28715a6 commit 233fc22

File tree

2 files changed

+59
-6
lines changed

2 files changed

+59
-6
lines changed

testing/run_tests.py

Lines changed: 22 additions & 1 deletion
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
@@ -752,6 +753,12 @@ def run_objc_tests(ios_variant='ios_debug_sim_unopt', test_filter=None):
752753
ios_unit_test_dir = os.path.join(
753754
BUILDROOT_DIR, 'flutter', 'testing', 'ios', 'IosUnitTests'
754755
)
756+
757+
result_bundle_temp = tempfile.TemporaryDirectory(
758+
suffix='ios_embedding_xcresult'
759+
).name
760+
result_bundle_path = os.path.join(result_bundle_temp, 'ios_embedding')
761+
755762
# Avoid using xcpretty unless the following can be addressed:
756763
# - Make sure all relevant failure output is printed on a failure.
757764
# - Make sure that a failing exit code is set for CI.
@@ -760,13 +767,27 @@ def run_objc_tests(ios_variant='ios_debug_sim_unopt', test_filter=None):
760767
'xcodebuild '
761768
'-sdk iphonesimulator '
762769
'-scheme IosUnitTests '
763-
"-destination name='" + new_simulator_name + "' "
770+
'-resultBundlePath ' + result_bundle_path + " -destination name='" +
771+
new_simulator_name + "' "
764772
'test '
765773
'FLUTTER_ENGINE=' + ios_variant
766774
]
767775
if test_filter is not None:
768776
test_command[0] = test_command[0] + ' -only-testing:%s' % test_filter
769777
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(result_bundle_temp, 'ios_embedding.xcresult')
785+
print(xcresult_bundle)
786+
if luci_test_outputs_path and os.path.exists(xcresult_bundle):
787+
dump_path = os.path.join(luci_test_outputs_path, 'ios_embedding.xcresult')
788+
# xcresults contain many little files. Archive the bundle before upload.
789+
shutil.make_archive(dump_path, 'zip', root_dir=xcresult_bundle)
790+
770791
finally:
771792
delete_simulator(new_simulator_name)
772793

testing/scenario_app/run_ios_tests.sh

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,57 @@ 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+
cd $SCENARIO_PATH
46+
47+
RESULT_BUNDLE_FOLDER="ios_scenario_xcresult"
48+
RESULT_BUNDLE_PATH="${SCENARIO_PATH}/${RESULT_BUNDLE_FOLDER}"
49+
50+
# Zip and upload xcresult to luci.
51+
# First parameter ($1) is the zip output name.
52+
ZIP_AND_UPLOAD_XCRESULT_TO_LUCI () {
53+
# Using RESULT_BUNDLE_PATH causes the zip containing all the sub directories.
54+
# So use relative directory instead.
55+
echo $1
56+
zip -q -r $1 "./$RESULT_BUNDLE_FOLDER"
57+
if ( -z "$FLUTTER_TEST_OUTPUTS_DIR") then
58+
mv -f $1 $FLUTTER_TEST_OUTPUTS_DIR
59+
fi
60+
exit 1
61+
}
4562

4663
echo "Running simulator tests with Skia"
4764
echo ""
4865

49-
set -o pipefail && xcodebuild -sdk iphonesimulator \
66+
mktemp -d $RESULT_BUNDLE_PATH
67+
trap 'rm -rf $RESULT_BUNDLE_PATH' EXIT
68+
69+
if set -o pipefail && xcodebuild -sdk iphonesimulator \
5070
-scheme Scenarios \
71+
-resultBundlePath "$RESULT_BUNDLE_PATH/ios_scenario.xcresult" \
5172
-destination 'platform=iOS Simulator,OS=16.2,name=iPhone SE (3rd generation)' \
5273
clean test \
53-
FLUTTER_ENGINE="$FLUTTER_ENGINE"
74+
FLUTTER_ENGINE="$FLUTTER_ENGINE"; then
75+
echo "test success."
76+
else
77+
echo "test failed."
78+
ZIP_AND_UPLOAD_XCRESULT_TO_LUCI "ios_scenario_xcresult.zip"
79+
fi
5480

5581
echo "Running simulator tests with Impeller"
5682
echo ""
5783

5884
# Skip testFontRenderingWhenSuppliedWithBogusFont: https://github.com/flutter/flutter/issues/113250
59-
set -o pipefail && xcodebuild -sdk iphonesimulator \
85+
if set -o pipefail && xcodebuild -sdk iphonesimulator \
6086
-scheme Scenarios \
87+
-resultBundlePath "$RESULT_BUNDLE_PATH/ios_scenario.xcresult" \
6188
-destination 'platform=iOS Simulator,OS=16.2,name=iPhone SE (3rd generation)' \
6289
clean test \
6390
FLUTTER_ENGINE="$FLUTTER_ENGINE" \
6491
-skip-testing "ScenariosUITests/BogusFontTextTest/testFontRenderingWhenSuppliedWithBogusFont" \
65-
INFOPLIST_FILE="Scenarios/Info_Impeller.plist" # Plist with FLTEnableImpeller=YES
92+
INFOPLIST_FILE="Scenarios/Info_Impeller.plist"; then # Plist with FLTEnableImpeller=YES
93+
echo "test success."
94+
else
95+
echo "test failed."
96+
ZIP_AND_UPLOAD_XCRESULT_TO_LUCI "ios_scenario_impeller_xcresult.zip"
97+
fi

0 commit comments

Comments
 (0)