def testGetParser(self, mock_xcode_version): mock_xcode_version.return_value = ('12.0', '12A7209') self.assertEqual(xcode_log_parser.get_parser().__class__.__name__, 'Xcode11LogParser') mock_xcode_version.return_value = ('11.4', '11E146') self.assertEqual(xcode_log_parser.get_parser().__class__.__name__, 'Xcode11LogParser') mock_xcode_version.return_value = ('10.3', '10G8') self.assertEqual(xcode_log_parser.get_parser().__class__.__name__, 'XcodeLogParser')
def __init__(self, egtests_app, udid, shards, retries, out_dir=os.path.basename(os.getcwd()), use_clang_coverage=False, env=None): """Initialize launch command. Args: egtests_app: (EgtestsApp) An egtests_app to run. udid: (str) UDID of a device/simulator. shards: (int) A number of shards. retries: (int) A number of retries. out_dir: (str) A folder in which xcodebuild will generate test output. By default it is a current directory. env: (dict) Environment variables. Raises: LaunchCommandCreationError: if one of parameters was not set properly. """ if not isinstance(egtests_app, test_apps.EgtestsApp): raise test_runner.AppNotFoundError( 'Parameter `egtests_app` is not EgtestsApp: %s' % egtests_app) self.egtests_app = egtests_app self.udid = udid self.shards = shards self.retries = retries self.out_dir = out_dir self.logs = collections.OrderedDict() self.test_results = collections.OrderedDict() self.use_clang_coverage = use_clang_coverage self.env = env self._log_parser = xcode_log_parser.get_parser()
def process_xcresult_dir(self): """Copies artifacts & diagnostic logs, zips and removes .xcresult dir.""" # .xcresult dir only exists when using Xcode 11+ and running as XCTest. if not xcode_util.using_xcode_11_or_higher() or not self.xctest: LOGGER.info('Skip processing xcresult directory.') xcresult_paths = [] # Warning: This piece of code assumes .xcresult folder is directly under # self.out_dir. This is true for TestRunner subclasses in this file. # xcresult folder path is whatever passed in -resultBundlePath to xcodebuild # command appended with '.xcresult' suffix. for filename in os.listdir(self.out_dir): full_path = os.path.join(self.out_dir, filename) if full_path.endswith('.xcresult') and os.path.isdir(full_path): xcresult_paths.append(full_path) log_parser = xcode_log_parser.get_parser() for xcresult in xcresult_paths: # This is what was passed in -resultBundlePath to xcodebuild command. result_bundle_path = os.path.splitext(xcresult)[0] log_parser.copy_artifacts(result_bundle_path) log_parser.export_diagnostic_data(result_bundle_path) # result_bundle_path is a symlink to xcresult directory. if os.path.islink(result_bundle_path): os.unlink(result_bundle_path) file_util.zip_and_remove_folder(xcresult)
def __init__(self, app_path, host_app_path, iossim_path, version, platform, out_dir, variations_seed_path, **kwargs): super(VariationsSimulatorParallelTestRunner, self).__init__(app_path, host_app_path, iossim_path, version, platform, out_dir, **kwargs) self.variations_seed_path = variations_seed_path self.host_app_bundle_id = test_apps.get_bundle_id(self.host_app_path) self.log_parser = xcode_log_parser.get_parser() self.test_app = self.get_launch_test_app()