[ios] Support --gtest_filter for iOS tests

Change-Id: I5511911110b58b7accd0f78cc1094924bfbda71e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4114702
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
This commit is contained in:
Ben Hamilton 2022-12-16 15:24:02 -07:00 committed by Crashpad LUCI CQ
parent 0e7dae459f
commit 62a0099c0e

View File

@ -312,7 +312,7 @@ def _RunOnAndroidTarget(binary_dir, test, android_device, extra_command_line):
_adb_shell(['rm', '-rf', device_temp_dir]) _adb_shell(['rm', '-rf', device_temp_dir])
def _RunOnIOSTarget(binary_dir, test, is_xcuitest=False): def _RunOnIOSTarget(binary_dir, test, is_xcuitest=False, gtest_filter=None):
"""Runs the given iOS |test| app on iPhone 8 with the default OS version.""" """Runs the given iOS |test| app on iPhone 8 with the default OS version."""
def xctest(binary_dir, test): def xctest(binary_dir, test):
@ -374,10 +374,13 @@ def _RunOnIOSTarget(binary_dir, test, is_xcuitest=False):
else: else:
plistlib.dump(xctest(binary_dir, test), fp) plistlib.dump(xctest(binary_dir, test), fp)
subprocess.check_call([ command = [
'xcodebuild', 'test-without-building', '-xctestrun', xctestrun_path, 'xcodebuild', 'test-without-building', '-xctestrun', xctestrun_path,
'-destination', 'platform=iOS Simulator,name=iPhone 8' '-destination', 'platform=iOS Simulator,name=iPhone 8',
]) ]
if gtest_filter:
command.append('-only-testing:' + test + '/' + gtest_filter)
subprocess.check_call(command)
# This script is primarily used from the waterfall so that the list of tests # This script is primarily used from the waterfall so that the list of tests
@ -468,7 +471,8 @@ def main(args):
elif is_ios: elif is_ios:
_RunOnIOSTarget(args.binary_dir, _RunOnIOSTarget(args.binary_dir,
test, test,
is_xcuitest=test.startswith('ios')) is_xcuitest=test.startswith('ios'),
gtest_filter=args.gtest_filter)
else: else:
subprocess.check_call([os.path.join(args.binary_dir, test)] + subprocess.check_call([os.path.join(args.binary_dir, test)] +
extra_command_line) extra_command_line)