From 0bb08cc36477251ddd8fa2c51b281eca83dee0bd Mon Sep 17 00:00:00 2001 From: Weiming Dai Date: Mon, 12 Nov 2018 14:39:36 +0800 Subject: [PATCH] Update test runner - Fix typo - Fix the compatibility issue in Xcode 8. --- .../test_runner/xcodebuild_test_executor.py | 6 ++-- xctestrunner/test_runner/xctestrun.py | 29 ++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/xctestrunner/test_runner/xcodebuild_test_executor.py b/xctestrunner/test_runner/xcodebuild_test_executor.py index d3f4c49..4665db4 100644 --- a/xctestrunner/test_runner/xcodebuild_test_executor.py +++ b/xctestrunner/test_runner/xcodebuild_test_executor.py @@ -243,9 +243,9 @@ def Execute(self, return_output=True): if _PROCESS_EXISTED_OR_CRASHED_ERROR in output_str: raise ios_errors.SimError('') if ios_constants.CORESIMULATOR_INTERRUPTED_ERROR in output_str: - # Sleep random[0,2] seconds to avoid race condition. It is known - # issue that CoreSimulatorService connection will interrupte if - # two simulators booting at the same time. + # Sleep random[0,2] seconds to avoid race condition. It is a known + # issue that CoreSimulatorService connection will be interrupted + # if two simulators are booting at the same time. time.sleep(random.uniform(0, 2)) raise ios_errors.SimError('') if (self._app_bundle_id and diff --git a/xctestrunner/test_runner/xctestrun.py b/xctestrunner/test_runner/xctestrun.py index 9b9bb92..0310136 100644 --- a/xctestrunner/test_runner/xctestrun.py +++ b/xctestrunner/test_runner/xctestrun.py @@ -396,12 +396,13 @@ def _GenerateTestRootForXcuitest(self): shutil.copytree( os.path.join(platform_library_path, 'Frameworks/XCTest.framework'), xctest_framework) - xct_automation_framework = os.path.join(runner_app_frameworks_dir, - 'XCTAutomationSupport.framework') - shutil.copytree( - os.path.join(platform_library_path, - 'PrivateFrameworks/XCTAutomationSupport.framework'), - xct_automation_framework) + if xcode_info_util.GetXcodeVersionNumber() >= 900: + xct_automation_framework = os.path.join(runner_app_frameworks_dir, + 'XCTAutomationSupport.framework') + shutil.copytree( + os.path.join(platform_library_path, + 'PrivateFrameworks/XCTAutomationSupport.framework'), + xct_automation_framework) self._PrepareUitestInRunerApp(uitest_runner_app) @@ -451,8 +452,9 @@ def _GenerateTestRootForXcuitest(self): self._app_under_test_dir) bundle_util.CodesignBundle( xctest_framework, identity=app_under_test_signing_identity) - bundle_util.CodesignBundle( - xct_automation_framework, identity=app_under_test_signing_identity) + if xcode_info_util.GetXcodeVersionNumber() >= 900: + bundle_util.CodesignBundle( + xct_automation_framework, identity=app_under_test_signing_identity) bundle_util.CodesignBundle( uitest_runner_app, entitlements_plist_path=entitlements_plist_path, @@ -504,12 +506,11 @@ def _GetUitestRunnerAppFromXcode(self, platform_library_path): os.path.join(uitest_runner_app, uitest_runner_app_name)) runner_app_info_plist_path = os.path.join(uitest_runner_app, 'Info.plist') - with open(runner_app_info_plist_path, 'r') as info_plist_file: - file_content = info_plist_file.read() - file_content = file_content.replace('WRAPPEDPRODUCTNAME', - uitest_runner_app_name) - with open(runner_app_info_plist_path, 'w') as info_plist_file: - info_plist_file.write(file_content) + info_plist = plist_util.Plist(runner_app_info_plist_path) + info_plist.SetPlistField('CFBundleName', uitest_runner_app_name) + info_plist.SetPlistField('CFBundleExecutable', uitest_runner_app_name) + info_plist.SetPlistField('CFBundleIdentifier', + 'com.apple.test.' + uitest_runner_app_name) return uitest_runner_app