Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(620)

Side by Side Diff: scripts/slave/ios/test_runner.py

Issue 2142243003: Add support for new iossim in Xcode 8. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build@master
Patch Set: Wipe home directory too Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Contains test runners for launching tests on simulators and devices.""" 6 """Contains test runners for launching tests on simulators and devices."""
7 7
8 # pylint: disable=relative-import 8 # pylint: disable=relative-import
9 import environment_setup 9 import environment_setup
10 10
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 raise XcodeVersionNotFoundError(xcode_version) 148 raise XcodeVersionNotFoundError(xcode_version)
149 149
150 self.gs_bucket = gs_bucket 150 self.gs_bucket = gs_bucket
151 self.perf_bot_name = perf_bot_name 151 self.perf_bot_name = perf_bot_name
152 self.perf_master_name = perf_master_name 152 self.perf_master_name = perf_master_name
153 self.perf_revision = perf_revision 153 self.perf_revision = perf_revision
154 self.perf_build_number = perf_build_number 154 self.perf_build_number = perf_build_number
155 self.perf_builder_name = perf_builder_name 155 self.perf_builder_name = perf_builder_name
156 self.perf_x_value = perf_x_value 156 self.perf_x_value = perf_x_value
157 self.test_args = test_args or [] 157 self.test_args = test_args or []
158 self.xcode_version = xcode_version
158 159
159 self.summary = { 160 self.summary = {
160 'links': collections.OrderedDict(), 161 'links': collections.OrderedDict(),
161 'logs': collections.OrderedDict(), 162 'logs': collections.OrderedDict(),
162 } 163 }
163 164
164 @staticmethod 165 @staticmethod
165 def Print(message, blank_lines=0, time_to_sleep=0): 166 def Print(message, blank_lines=0, time_to_sleep=0):
166 """Prints a message. 167 """Prints a message.
167 168
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 '-c', 'Print:CFBundleIdentifier', 481 '-c', 'Print:CFBundleIdentifier',
481 os.path.join(self.app_path, 'Info.plist'), 482 os.path.join(self.app_path, 'Info.plist'),
482 ).stdout[0] 483 ).stdout[0]
483 484
484 self.iossim_path = iossim_path 485 self.iossim_path = iossim_path
485 self.platform = platform 486 self.platform = platform
486 self.version = version 487 self.version = version
487 self.timeout = '120' 488 self.timeout = '120'
488 self.homedir = '' 489 self.homedir = ''
489 self.start_time = None 490 self.start_time = None
491 self.xcode_version = xcode_version
490 492
491 def SetStartTime(self): 493 def SetStartTime(self):
492 """Sets the start time, for finding crash reports during this run.""" 494 """Sets the start time, for finding crash reports during this run."""
493 # Crash reports have a timestamp in their filename, formatted as 495 # Crash reports have a timestamp in their filename, formatted as
494 # YYYY-MM-DD-HHMMSS. 496 # YYYY-MM-DD-HHMMSS.
495 self.start_time = time.strftime('%Y-%m-%d-%H%M%S', time.localtime()) 497 self.start_time = time.strftime('%Y-%m-%d-%H%M%S', time.localtime())
496 498
497 def CreateNewHomeDirectory(self): 499 def CreateNewHomeDirectory(self):
498 """Creates a new home directory for the simulator.""" 500 """Creates a new home directory for the simulator."""
499 self.homedir = tempfile.mkdtemp() 501 if self.xcode_version == '8.0':
502 cmd = [
503 self.iossim_path,
504 '-d', self.platform,
505 '-s', self.version,
506 '-w'
507 ]
508 subprocess.check_output(cmd)
509 cmd = [
510 self.iossim_path,
511 '-d', self.platform,
512 '-s', self.version,
513 '-p'
514 ]
515 self.homedir = subprocess.check_output(cmd)
516 else:
517 self.homedir = tempfile.mkdtemp()
518
500 519
501 def RemoveHomeDirectory(self): 520 def RemoveHomeDirectory(self):
502 """Recursively removes the home directory being used by the simulator.""" 521 """Recursively removes the home directory being used by the simulator."""
503 if os.path.exists(self.homedir): 522 if self.xcode_version == '8.0':
504 shutil.rmtree(self.homedir, ignore_errors=True) 523 cmd = [
524 self.iossim_path,
525 '-d', self.platform,
526 '-s', self.version,
527 '-w'
528 ]
529 subprocess.check_output(cmd)
505 self.homedir = '' 530 self.homedir = ''
531 else:
532 if os.path.exists(self.homedir):
533 shutil.rmtree(self.homedir, ignore_errors=True)
534 self.homedir = ''
506 535
507 def KillSimulators(self): 536 def KillSimulators(self):
508 """Forcibly kills any running iOS simulator instances.""" 537 """Forcibly kills any running iOS simulator instances."""
509 kill_cmd = [ 538 kill_cmd = [
510 'pkill', 539 'pkill',
511 '-9', 540 '-9',
512 '-x', 541 '-x',
513 # The iOS simulator has a different name depending on the Xcode version. 542 # The iOS simulator has a different name depending on the Xcode version.
514 'iPhone Simulator', # Xcode 5 543 'iPhone Simulator', # Xcode 5
515 'iOS Simulator', # Xcode 6 544 'iOS Simulator', # Xcode 6
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 blacklist: Whether to blacklist the elements of test_filter or not. Only 704 blacklist: Whether to blacklist the elements of test_filter or not. Only
676 works when test_filter is not None. 705 works when test_filter is not None.
677 706
678 Returns: 707 Returns:
679 A list whose elements are the args representing the command. 708 A list whose elements are the args representing the command.
680 """ 709 """
681 cmd = [ 710 cmd = [
682 self.iossim_path, 711 self.iossim_path,
683 '-d', self.platform, 712 '-d', self.platform,
684 '-s', self.version, 713 '-s', self.version,
685 '-t', self.timeout,
686 '-u', self.homedir,
687 ] 714 ]
688 args = [] 715 args = []
689 716
717 if self.xcode_version != '8.0':
718 cmd.extend([
719 '-t', self.timeout,
720 '-u', self.homedir
721 ])
722
690 if test_filter is not None: 723 if test_filter is not None:
691 kif_filter = self.GetKIFTestFilter(test_filter, blacklist) 724 kif_filter = self.GetKIFTestFilter(test_filter, blacklist)
692 gtest_filter = self.GetGTestFilter(test_filter, blacklist) 725 gtest_filter = self.GetGTestFilter(test_filter, blacklist)
693 726
694 cmd.extend([ 727 cmd.extend([
695 '-e', 'GKIF_SCENARIO_FILTER=%s' % kif_filter, 728 '-e', 'GKIF_SCENARIO_FILTER=%s' % kif_filter,
696 ]) 729 ])
697 args.append('--gtest_filter=%s' % gtest_filter) 730
731 if self.xcode_version == '8.0':
732 cmd.extend([
733 '-c', '--gtest_filter=%s' % gtest_filter,
734 ])
735 else:
736 args.append('--gtest_filter=%s' % gtest_filter)
698 737
699 cmd.append(self.app_path) 738 cmd.append(self.app_path)
700 cmd.extend(self.test_args) 739 cmd.extend(self.test_args)
701 cmd.extend(args) 740 cmd.extend(args)
702 return cmd 741 return cmd
703 742
704 @TestRunner.RequireTearDown 743 @TestRunner.RequireTearDown
705 def Launch(self, *args, **kwargs): 744 def Launch(self, *args, **kwargs):
706 """Launches the test.""" 745 """Launches the test."""
707 self.SetUp() 746 self.SetUp()
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 ) 1428 )
1390 1429
1391 # Uninstall and re-install the app. 1430 # Uninstall and re-install the app.
1392 self.UninstallApp() 1431 self.UninstallApp()
1393 self.InstallApp() 1432 self.InstallApp()
1394 1433
1395 result = self._Run( 1434 result = self._Run(
1396 self.GetLaunchCommand(), self.GetLaunchEnvironment(), *args, **kwargs) 1435 self.GetLaunchCommand(), self.GetLaunchEnvironment(), *args, **kwargs)
1397 1436
1398 return self.RunAllTests(result, *args, **kwargs) 1437 return self.RunAllTests(result, *args, **kwargs)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698