From bd479a120237da52046e0932a886c021b745b893 Mon Sep 17 00:00:00 2001 From: Ben Hamilton Date: Tue, 20 Dec 2022 13:27:14 -0700 Subject: [PATCH] [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 Commit-Queue: Ben Hamilton --- build/run_tests.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/build/run_tests.py b/build/run_tests.py index eec7be47..e03e06e7 100755 --- a/build/run_tests.py +++ b/build/run_tests.py @@ -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)