Commit 0c71cc06 authored by zhaoyangli's avatar zhaoyangli Committed by Commit Bot

[iOS][test runner] Make DeviceTestRunner run xctest through xctest arg.

This change makes DeviceTestRunner also run target as XCTest by checking
xctest arg. Before this change, DeviceTestRunner uses solely the
existence of ".xctest" to determine if the target should run as XCTest.
This can cause trouble when targets build .xctest in but do not wish to
run as it.

The goal is to only use xctest arg to determine if it should run as
XCTest. These follow up CLs are needed to achieve the goal:
- Change device XCTest unit test configs in multiple repos.
- Remove the logic of using xctest_path to determine if run with xctest,
add a check to ensure xctest path is there when xctest is true.

Bug: 1085603
Change-Id: I07e5f21467791295e8ecc5f6246e58fd696d5e4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2412970
Commit-Queue: Zhaoyang Li <zhaoyangli@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807608}
parent b2ae430d
......@@ -569,11 +569,26 @@ class TestRunner(object):
# target. For simulators, '--xctest' is passed to test runner scripts to
# make it run XCTest based unit test.
if self.xctest:
# TODO(crbug.com/1085603): Pass in test runner an arg to determine if it's
# device test or simulator test and test the arg here.
if self.__class__.__name__ == 'SimulatorTestRunner':
test_app = test_apps.SimulatorXCTestUnitTestsApp(
self.app_path,
included_tests=self.test_cases,
env_vars=self.env_vars,
test_args=self.test_args)
elif self.__class__.__name__ == 'DeviceTestRunner':
test_app = test_apps.DeviceXCTestUnitTestsApp(
self.app_path,
included_tests=self.test_cases,
env_vars=self.env_vars,
test_args=self.test_args)
else:
raise XCTestConfigError('Wrong config. TestRunner.launch() called from'
' an unexpected class.')
# TODO(crbug.com/1085603): Remove when device unit tests have xctest in
# configs.
elif self.xctest_path:
if self.__class__.__name__ == 'DeviceTestRunner':
......@@ -1086,7 +1101,9 @@ class DeviceTestRunner(TestRunner):
Returns:
A list of strings forming the command to launch the test.
"""
if self.xctest_path:
# TODO(crbug.com/1085603): Remove self.xctest_path check when device unit
# tests have xctest in configs.
if self.xctest_path or self.xctest:
return test_app.command(out_dir, destination, shards)
cmd = [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment