From ca459834494677589e76d99f208b7352edd0e1bf Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Fri, 3 Mar 2023 10:54:01 -0800 Subject: [PATCH] Upload xcresults to LUCI cloud storage --- testing/run_tests.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/testing/run_tests.py b/testing/run_tests.py index 98509be2b153a..0c1703cad7634 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -17,6 +17,7 @@ import multiprocessing import os import re +import shutil import subprocess import sys import tempfile @@ -728,6 +729,12 @@ def run_objc_tests(ios_variant='ios_debug_sim_unopt', test_filter=None): ios_unit_test_dir = os.path.join( BUILDROOT_DIR, 'flutter', 'testing', 'ios', 'IosUnitTests' ) + + result_bundle_temp = tempfile.TemporaryDirectory( + suffix='ios_embedding_xcresult' + ).name + result_bundle_path = os.path.join(result_bundle_temp, 'ios_embedding') + # Avoid using xcpretty unless the following can be addressed: # - Make sure all relevant failure output is printed on a failure. # - Make sure that a failing exit code is set for CI. @@ -736,13 +743,27 @@ def run_objc_tests(ios_variant='ios_debug_sim_unopt', test_filter=None): 'xcodebuild ' '-sdk iphonesimulator ' '-scheme IosUnitTests ' - "-destination name='" + new_simulator_name + "' " + '-resultBundlePath ' + result_bundle_path + " -destination name='" + + new_simulator_name + "' " 'test ' 'FLUTTER_ENGINE=' + ios_variant ] if test_filter is not None: test_command[0] = test_command[0] + ' -only-testing:%s' % test_filter run_cmd(test_command, cwd=ios_unit_test_dir, shell=True) + + # except: + # The LUCI environment may provide a variable containing a directory path + # for additional output files that will be uploaded to cloud storage. + # Upload the xcresult when the tests fail. + luci_test_outputs_path = os.environ.get('FLUTTER_TEST_OUTPUTS_DIR') + xcresult_bundle = os.path.join(result_bundle_temp, 'ios_embedding.xcresult') + print(xcresult_bundle) + if luci_test_outputs_path and os.path.exists(xcresult_bundle): + dump_path = os.path.join(luci_test_outputs_path, 'ios_embedding.xcresult') + # xcresults contain many little files. Archive the bundle before upload. + shutil.make_archive(dump_path, 'zip', root_dir=xcresult_bundle) + finally: delete_simulator(new_simulator_name)