[ios] Fix --gtest_filter for non-xcuitest targets

Change-Id: I477919feec68d317ca3cb8a0d07022e9405156dd
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4118347
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
This commit is contained in:
Ben Hamilton 2022-12-20 13:27:14 -07:00 committed by Crashpad LUCI CQ
parent 62a0099c0e
commit bd479a1202

View File

@ -315,7 +315,7 @@ def _RunOnAndroidTarget(binary_dir, test, android_device, extra_command_line):
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."""
def xctest(binary_dir, test):
def xctest(binary_dir, test, gtest_filter=None):
"""Returns a dict containing the xctestrun data needed to run an
XCTest-based test app."""
test_path = os.path.join(CRASHPAD_DIR, binary_dir)
@ -332,6 +332,8 @@ def _RunOnIOSTarget(binary_dir, test, is_xcuitest=False, gtest_filter=None):
'XCInjectBundleInto': '__TESTHOST__/' + test,
}
}
if gtest_filter:
module_data['CommandLineArguments'] = ['--gtest_filter='+gtest_filter]
return {test: module_data}
def xcuitest(binary_dir, test):
@ -368,18 +370,17 @@ def _RunOnIOSTarget(binary_dir, test, is_xcuitest=False, gtest_filter=None):
xctestrun_path = f.name
print(xctestrun_path)
with open(xctestrun_path, 'wb') as fp:
if is_xcuitest:
plistlib.dump(xcuitest(binary_dir, test), fp)
else:
plistlib.dump(xctest(binary_dir, test), fp)
command = [
'xcodebuild', 'test-without-building', '-xctestrun', xctestrun_path,
'-destination', 'platform=iOS Simulator,name=iPhone 8',
]
if gtest_filter:
command.append('-only-testing:' + test + '/' + gtest_filter)
with open(xctestrun_path, 'wb') as fp:
if is_xcuitest:
plistlib.dump(xcuitest(binary_dir, test), fp)
if gtest_filter:
command.append('-only-testing:' + test + '/' + gtest_filter)
else:
plistlib.dump(xctest(binary_dir, test, gtest_filter), fp)
subprocess.check_call(command)