Create iOS simulator before running IosUnitTests (flutter/engine#33906)
This commit is contained in:
@@ -605,25 +605,53 @@ def RunObjcTests(ios_variant='ios_debug_sim_unopt', test_filter=None):
|
||||
ios_out_dir = os.path.join(out_dir, ios_variant)
|
||||
EnsureIosTestsAreBuilt(ios_out_dir)
|
||||
|
||||
ios_unit_test_dir = os.path.join(
|
||||
buildroot_dir, 'flutter', 'testing', 'ios', 'IosUnitTests'
|
||||
)
|
||||
new_simulator_name = 'IosUnitTestsSimulator'
|
||||
|
||||
# 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.
|
||||
# See https://github.com/flutter/flutter/issues/63742
|
||||
command = [
|
||||
'xcodebuild '
|
||||
'-sdk iphonesimulator '
|
||||
'-scheme IosUnitTests '
|
||||
"-destination platform='iOS Simulator,name=iPhone 11' "
|
||||
'test '
|
||||
'FLUTTER_ENGINE=' + ios_variant
|
||||
# Delete simulators with this name in case any were leaked
|
||||
# from another test run.
|
||||
DeleteSimulator(new_simulator_name)
|
||||
|
||||
create_simulator = [
|
||||
'xcrun '
|
||||
'simctl '
|
||||
'create '
|
||||
'%s com.apple.CoreSimulator.SimDeviceType.iPhone-11' % new_simulator_name
|
||||
]
|
||||
if test_filter != None:
|
||||
command[0] = command[0] + " -only-testing:%s" % test_filter
|
||||
RunCmd(command, cwd=ios_unit_test_dir, shell=True)
|
||||
RunCmd(create_simulator, shell=True)
|
||||
|
||||
try:
|
||||
ios_unit_test_dir = os.path.join(
|
||||
buildroot_dir, 'flutter', 'testing', 'ios', 'IosUnitTests'
|
||||
)
|
||||
# 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.
|
||||
# See https://github.com/flutter/flutter/issues/63742
|
||||
test_command = [
|
||||
'xcodebuild '
|
||||
'-sdk iphonesimulator '
|
||||
'-scheme IosUnitTests '
|
||||
"-destination name='" + new_simulator_name + "' "
|
||||
'test '
|
||||
'FLUTTER_ENGINE=' + ios_variant
|
||||
]
|
||||
if test_filter != None:
|
||||
test_command[0] = test_command[0] + " -only-testing:%s" % test_filter
|
||||
RunCmd(test_command, cwd=ios_unit_test_dir, shell=True)
|
||||
finally:
|
||||
DeleteSimulator(new_simulator_name)
|
||||
|
||||
|
||||
def DeleteSimulator(simulator_name):
|
||||
# Will delete all simulators with this name.
|
||||
delete_simulator = [
|
||||
'xcrun',
|
||||
'simctl',
|
||||
'delete',
|
||||
simulator_name,
|
||||
]
|
||||
# Let this fail if the simulator was never created.
|
||||
RunCmd(delete_simulator, expect_failure=True)
|
||||
|
||||
|
||||
def GatherDartTests(build_dir, filter, verbose_dart_snapshot):
|
||||
|
||||
Reference in New Issue
Block a user