Commit ee3d9cb5 authored by Garrett Beaty's avatar Garrett Beaty Committed by Commit Bot

Revert "[ios]Removed usage of iossim in ios/build/bots/scripts/*"

This reverts commit 16469ef3.

Reason for revert: The recipe change that stops setting iossim breaks the builder on the beta branch: https://ci.chromium.org/p/chromium/builders/ci-beta/ios-simulator/463

Original change's description:
> [ios]Removed usage of iossim in ios/build/bots/scripts/*
>
> Bug: 1011498
> Change-Id: Ie72335fb20a8ee5c47ba8edaf4ed8299068a7f40
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2067325
> Commit-Queue: Maksym Onufriienko <monufriienko@chromium.org>
> Reviewed-by: Rohit Rao <rohitrao@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#744748}

TBR=rohitrao@chromium.org,lindsayw@chromium.org,monufriienko@chromium.org,zhaoyangli@chromium.org


Bug: 1011498, 1056905
Change-Id: I45689abac093072e819b19d38ed6855309045725
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079521Reviewed-by: default avatarGarrett Beaty <gbeaty@chromium.org>
Commit-Queue: Garrett Beaty <gbeaty@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745312}
parent d7a0292c
......@@ -5,7 +5,6 @@
import iossim_util
import mock
import test_runner
import test_runner_test
......@@ -15,21 +14,17 @@ class GetiOSSimUtil(test_runner_test.TestCase):
def setUp(self):
super(GetiOSSimUtil, self).setUp()
self.mock(iossim_util, 'get_simulator_list',
lambda: test_runner_test.SIMULATORS_LIST)
def test_get_simulator_runtime_by_version(self):
"""Ensures correctness of filter."""
self.assertEqual(
'com.apple.CoreSimulator.SimRuntime.iOS-13-2',
iossim_util.get_simulator_runtime_by_version(
test_runner_test.SIMULATORS_LIST, '13.2.2'))
iossim_util.get_simulator_runtime_by_version(SIMULATORS_LIST, '13.2.2'))
def test_get_simulator_runtime_by_version_not_found(self):
"""Ensures that SimulatorNotFoundError raises if no runtime."""
with self.assertRaises(test_runner.SimulatorNotFoundError) as context:
iossim_util.get_simulator_runtime_by_version(
test_runner_test.SIMULATORS_LIST, '13.2')
iossim_util.get_simulator_runtime_by_version(SIMULATORS_LIST, '13.2')
expected_message = ('Simulator does not exist: Not found '
'"13.2" SDK in runtimes')
self.assertTrue(expected_message in str(context.exception))
......@@ -38,14 +33,14 @@ class GetiOSSimUtil(test_runner_test.TestCase):
"""Ensures correctness of filter."""
self.assertEqual(
'com.apple.CoreSimulator.SimDeviceType.iPhone-11',
iossim_util.get_simulator_runtime_by_platform(
test_runner_test.SIMULATORS_LIST, 'iPhone 11'))
iossim_util.get_simulator_runtime_by_platform(SIMULATORS_LIST,
'iPhone 11'))
def test_get_simulator_runtime_by_platform_not_found(self):
"""Ensures that SimulatorNotFoundError raises if no platform."""
with self.assertRaises(test_runner.SimulatorNotFoundError) as context:
iossim_util.get_simulator_runtime_by_platform(
test_runner_test.SIMULATORS_LIST, 'iPhone XI')
iossim_util.get_simulator_runtime_by_platform(SIMULATORS_LIST,
'iPhone XI')
expected_message = ('Simulator does not exist: Not found device '
'"iPhone XI" in devicetypes')
self.assertTrue(expected_message in str(context.exception))
......
......@@ -140,6 +140,7 @@ class Runner():
tr = xcodebuild_runner.SimulatorParallelTestRunner(
self.args.app,
self.args.host_app,
self.args.iossim,
self.args.version,
self.args.platform,
out_dir=self.args.out_dir,
......@@ -153,6 +154,7 @@ class Runner():
tr = wpr_runner.WprProxySimulatorTestRunner(
self.args.app,
self.args.host_app,
self.args.iossim,
self.args.replay_path,
self.args.platform,
self.args.version,
......@@ -165,9 +167,10 @@ class Runner():
test_cases=self.args.test_cases,
xctest=self.args.xctest,
)
elif self.args.platform and self.args.version:
elif self.args.iossim and self.args.platform and self.args.version:
tr = test_runner.SimulatorTestRunner(
self.args.app,
self.args.iossim,
self.args.platform,
self.args.version,
self.args.out_dir,
......@@ -277,6 +280,12 @@ class Runner():
default='NO_PATH',
metavar='host_app',
)
parser.add_argument(
'-i',
'--iossim',
help='Compiled iossim to run the app on.',
metavar='iossim',
)
parser.add_argument(
'-j',
'--args-json',
......@@ -411,12 +420,12 @@ class Runner():
Runs argument validation
"""
if (not (args.xcode_parallelization or args.xcodebuild_device_runner) and
(args.platform or args.version)):
# If --platform or --version are specified then
# they must all be specified.
if not (args.platform and args.version):
(args.iossim or args.platform or args.version)):
# If any of --iossim, --platform, or --version
# are specified then they must all be specified.
if not (args.iossim and args.platform and args.version):
parser.error('must specify all or none of '
'-p/--platform, -v/--version')
'-i/--iossim, -p/--platform, -v/--version')
if args.xcode_parallelization and not (args.platform and args.version):
parser.error('--xcode-parallelization also requires '
......
......@@ -31,6 +31,69 @@ class UnitTest(unittest.TestCase):
runner.parse_args(cmd)
self.assertTrue(runner.args.app == './foo-Runner.app')
def test_parse_args_iossim_platform_version(self):
"""
iossim, platforma and version should all be set.
missing iossim
"""
test_cases = [
{
'error':
2,
'cmd': [
'--platform',
'iPhone X',
'--version',
'13.2.2',
# Required
'--xcode-build-version',
'123abc',
'--out-dir',
'some/dir'
],
},
{
'error':
2,
'cmd': [
'--iossim',
'path/to/iossim',
'--version',
'13.2.2',
# Required
'--xcode-build-version',
'123abc',
'--out-dir',
'some/dir'
],
},
{
'error':
2,
'cmd': [
'--iossim',
'path/to/iossim',
'--platform',
'iPhone X',
# Required
'--xcode-build-version',
'123abc',
'--out-dir',
'some/dir'
],
},
]
runner = run.Runner()
for test_case in test_cases:
with self.assertRaises(SystemExit) as ctx:
runner.parse_args(test_case['cmd'])
self.assertTrue(re.match('must specify all or none of *', ctx.message))
self.assertEqual(ctx.exception.code, test_case['error'])
def test_parse_args_xcode_parallelization_requirements(self):
"""
xcode parallelization set requires both platform and version
......
......@@ -685,11 +685,12 @@ class TestRunner(object):
class SimulatorTestRunner(TestRunner):
"""Class for running tests on iOS Simulators."""
"""Class for running tests on iossim."""
def __init__(
self,
app_path,
iossim_path,
platform,
version,
out_dir,
......@@ -706,10 +707,11 @@ class SimulatorTestRunner(TestRunner):
Args:
app_path: Path to the compiled .app or .ipa to run.
iossim_path: Path to the compiled iossim binary to use.
platform: Name of the platform to simulate. Supported values can be found
by running "xcrun simctl list". e.g. "iPhone 5s", "iPad Retina".
by running "iossim -l". e.g. "iPhone 5s", "iPad Retina".
version: Version of iOS the platform should be running. Supported values
can be found by running "xcrun simctl list". e.g. "9.3", "8.2", "7.1".
can be found by running "iossim -l". e.g. "9.3", "8.2", "7.1".
out_dir: Directory to emit test data into.
env_vars: List of environment variables to pass to the test itself.
retries: Number of times to retry failed test cases.
......@@ -736,7 +738,13 @@ class SimulatorTestRunner(TestRunner):
test_cases=test_cases,
xctest=xctest,
)
iossim_path = os.path.abspath(iossim_path)
if not os.path.exists(iossim_path):
raise SimulatorNotFoundError(iossim_path)
self.homedir = ''
self.iossim_path = iossim_path
self.platform = platform
self.start_time = None
self.version = version
......
......@@ -161,6 +161,7 @@ class SimulatorTestRunnerTest(TestCase):
with self.assertRaises(test_runner.AppNotFoundError):
test_runner.SimulatorTestRunner(
'fake-app',
'fake-iossim',
'platform',
'os',
'xcode-version',
......@@ -168,10 +169,26 @@ class SimulatorTestRunnerTest(TestCase):
'out-dir',
)
def test_iossim_not_found(self):
"""Ensures SimulatorNotFoundError is raised."""
self.mock(os.path, 'exists', lambda p: not p.endswith('fake-iossim'))
with self.assertRaises(test_runner.SimulatorNotFoundError):
test_runner.SimulatorTestRunner(
'fake-app',
'fake-iossim',
'iPhone X',
'11.4',
'xcode-version',
'xcode-build',
'out-dir',
)
def test_init(self):
"""Ensures instance is created."""
tr = test_runner.SimulatorTestRunner(
'fake-app',
'fake-iossim',
'iPhone X',
'11.4',
'xcode-version',
......@@ -200,6 +217,7 @@ class SimulatorTestRunnerTest(TestCase):
tr = test_runner.SimulatorTestRunner(
'fake-app',
'fake-iossim',
'iPhone X',
'11.4',
'xcode-version',
......@@ -225,6 +243,7 @@ class SimulatorTestRunnerTest(TestCase):
tr = test_runner.SimulatorTestRunner(
'fake-app',
'fake-iossim',
'iPhone X',
'11.4',
'xcode-version',
......@@ -249,6 +268,7 @@ class SimulatorTestRunnerTest(TestCase):
with self.assertRaises(test_runner.SystemAlertPresentError):
tr = test_runner.SimulatorTestRunner(
'fake-app',
'fake-iossim',
'iPhone X',
'11.4',
'xcode-version',
......@@ -265,6 +285,7 @@ class SimulatorTestRunnerTest(TestCase):
test_cases."""
tr = test_runner.SimulatorTestRunner(
'fake-app',
'fake-iossim',
'iPhone X',
'11.4',
'xcode-version',
......@@ -338,6 +359,7 @@ class SimulatorTestRunnerTest(TestCase):
tr = test_runner.SimulatorTestRunner(
'fake-app',
'fake-iossim',
'iPhone X',
'11.4',
'xcode-version',
......
......@@ -50,6 +50,7 @@ class WprProxySimulatorTestRunner(test_runner.SimulatorTestRunner):
self,
app_path,
host_app_path,
iossim_path,
replay_path,
platform,
version,
......@@ -67,11 +68,12 @@ class WprProxySimulatorTestRunner(test_runner.SimulatorTestRunner):
Args:
app_path: Path to the compiled .app or .ipa to run.
host_app_path: A path to the host app for EG2.
iossim_path: Path to the compiled iossim binary to use.
replay_path: Path to the folder where WPR replay and recipe files live.
platform: Name of the platform to simulate. Supported values can be found
by running "xcrun simctl list". e.g. "iPhone 5s", "iPad Retina".
by running "iossim -l". e.g. "iPhone 5s", "iPad Retina".
version: Version of iOS the platform should be running. Supported values
can be found by running "xcrun simctl list". e.g. "9.3", "8.2", "7.1".
can be found by running "iossim -l". e.g. "9.3", "8.2", "7.1".
wpr_tools_path: Path to pre-installed (from CIPD) WPR-related tools
out_dir: Directory to emit test data into.
env_vars: List of environment variables to pass to the test itself.
......@@ -89,6 +91,7 @@ class WprProxySimulatorTestRunner(test_runner.SimulatorTestRunner):
"""
super(WprProxySimulatorTestRunner, self).__init__(
app_path,
iossim_path,
platform,
version,
out_dir,
......
......@@ -51,6 +51,7 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase):
wpr_runner.WprProxySimulatorTestRunner(
'fake-app',
'bad-host-app-path',
'fake-iossim',
'replay-path',
'platform',
'os',
......@@ -69,6 +70,7 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase):
wpr_runner.WprProxySimulatorTestRunner(
'fake-app',
'fake-host-app',
'fake-iossim',
'bad-replay-path',
'platform',
'os',
......@@ -87,6 +89,7 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase):
wpr_runner.WprProxySimulatorTestRunner(
'fake-app',
'fake-host-app',
'fake-iossim',
'replay-path',
'platform',
'os',
......@@ -101,6 +104,7 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase):
tr = wpr_runner.WprProxySimulatorTestRunner(
'fake-app',
'fake-host-app',
'fake-iossim',
'replay-path',
'platform',
'os',
......@@ -156,6 +160,7 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase):
tr = wpr_runner.WprProxySimulatorTestRunner(
'fake-app',
'fake-host-app',
'fake-iossim',
'replay-path',
'platform',
'os',
......
......@@ -260,6 +260,7 @@ class SimulatorParallelTestRunner(test_runner.SimulatorTestRunner):
def __init__(self,
app_path,
host_app_path,
iossim_path,
version,
platform,
out_dir,
......@@ -274,6 +275,8 @@ class SimulatorParallelTestRunner(test_runner.SimulatorTestRunner):
Args:
app_path: (str) A path to egtests_app.
host_app_path: (str) A path to the host app for EG2.
iossim_path: Path to the compiled iossim binary to use.
Not used, but is required by the base class.
version: (str) iOS version to run simulator on.
platform: (str) Name of device.
out_dir: (str) A directory to emit test data into.
......@@ -294,6 +297,7 @@ class SimulatorParallelTestRunner(test_runner.SimulatorTestRunner):
"""
super(SimulatorParallelTestRunner, self).__init__(
app_path,
iossim_path,
platform,
version,
out_dir,
......
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