def getSimulator(self): """Gets a simulator or creates a new one by device types and runtimes. Returns the udid for the created simulator instance. Returns: An udid of a simulator device. """ return iossim_util.get_simulator(self.platform, self.version)
def __init__(self, app_path, iossim_path, platform, version, out_dir, **kwargs): """Initializes a new instance of this class. 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 "iossim -l". e.g. "iPhone 5s", "iPad Retina". version: Version of iOS the platform should be running. Supported values can be found by running "iossim -l". e.g. "9.3", "8.2", "7.1". out_dir: Directory to emit test data into. (Following are potential args in **kwargs) env_vars: List of environment variables to pass to the test itself. repeat_count: Number of times to run each test case (passed to test app). retries: Number of times to retry failed test cases. test_args: List of strings to pass as arguments to the test when launching. test_cases: List of tests to be included in the test run. None or [] to include all tests. use_clang_coverage: Whether code coverage is enabled in this run. wpr_tools_path: Path to pre-installed WPR-related tools xctest: Whether or not this is an XCTest. Raises: AppNotFoundError: If the given app does not exist. PlugInsNotFoundError: If the PlugIns directory does not exist for XCTests. XcodeVersionNotFoundError: If the given Xcode version does not exist. XCTestPlugInNotFoundError: If the .xctest PlugIn does not exist. """ super(SimulatorTestRunner, self).__init__(app_path, out_dir, **kwargs) 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 self.shards = kwargs.get('shards') or 1 self.udid = iossim_util.get_simulator(self.platform, self.version) self.use_clang_coverage = kwargs.get('use_clang_coverage') or False
def _init_sharding_data(self): """Initialize sharding data. For common case info about sharding tests will be a list of dictionaries: [ { 'app':paths to egtests_app, 'udid': 'UDID of Simulator' 'shards': N } ] """ self.sharding_data = [{ 'app': self.app_path, 'host': self.host_app_path, 'udid': iossim_util.get_simulator(self.platform, self.version), 'shards': self.shards, 'test_cases': self.test_cases }]
def __init__( self, app_path, iossim_path, platform, version, xcode_build_version, out_dir, env_vars=None, mac_toolchain='', retries=None, shards=None, test_args=None, test_cases=None, wpr_tools_path='', xcode_path='', xctest=False, ): """Initializes a new instance of this class. 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 "iossim -l". e.g. "iPhone 5s", "iPad Retina". version: Version of iOS the platform should be running. Supported values can be found by running "iossim -l". e.g. "9.3", "8.2", "7.1". xcode_build_version: Xcode build version to install before running tests. out_dir: Directory to emit test data into. env_vars: List of environment variables to pass to the test itself. mac_toolchain: Command to run `mac_toolchain` tool. retries: Number of times to retry failed test cases. test_args: List of strings to pass as arguments to the test when launching. test_cases: List of tests to be included in the test run. None or [] to include all tests. wpr_tools_path: Path to pre-installed WPR-related tools xcode_path: Path to Xcode.app folder where its contents will be installed. xctest: Whether or not this is an XCTest. Raises: AppNotFoundError: If the given app does not exist. PlugInsNotFoundError: If the PlugIns directory does not exist for XCTests. XcodeVersionNotFoundError: If the given Xcode version does not exist. XCTestPlugInNotFoundError: If the .xctest PlugIn does not exist. """ super(SimulatorTestRunner, self).__init__( app_path, xcode_build_version, out_dir, env_vars=env_vars, mac_toolchain=mac_toolchain, retries=retries, test_args=test_args, test_cases=test_cases, xcode_path=xcode_path, 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 self.shards = shards self.wpr_tools_path = wpr_tools_path self.udid = iossim_util.get_simulator(self.platform, self.version)
def test_no_new_sim_created_when_one_exists(self, mock_create, _): """Ensures no simulator is created when one in desired dimension exists.""" self.assertEqual('A4E66321-177A-450A-9BA1-488D85B7278E', iossim_util.get_simulator('iPhone 11', '13.2.2')) self.assertFalse(mock_create.called)
'--out-dir', default='/tmp/cwt_chromedriver', help='Output directory for CWTChromeDriver\'s dummy test case') parser.add_argument('--os', default='14.3', help='iOS version') parser.add_argument('--device', default='iPhone 11 Pro', help='Device type') parser.add_argument('--asan-build', help='Use ASan-related libraries', dest='asan_build', action='store_true') parser.set_defaults(asan_build=False) args = parser.parse_args() test_app = os.path.join(args.build_dir, 'ios_cwt_chromedriver_tests_module-Runner.app') host_app = os.path.join(args.build_dir, 'ios_cwt_chromedriver_tests.app') destination = iossim_util.get_simulator(args.device, args.os) if not os.path.exists(args.out_dir): os.mkdir(args.out_dir) # Make sure each run produces a unique output directory, since reusing an # existing directory will cause CWTChromeDriver's dummy test case to get # skipped, meaning that CWTChromeDriver's http server won't get launched. output_directory = os.path.join(args.out_dir, 'run%d' % int(time.time())) inserted_libs = [] if args.asan_build: inserted_libs = [ os.path.join(args.build_dir, 'libclang_rt.asan_iossim_dynamic.dylib') ]