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

Side by Side Diff: googletest/run_test_cases.py

Issue 25478012: Make Progress support an arbitrary number of columns. (Closed) Base URL: https://chromium.googlesource.com/a/chromium/tools/swarm_client@1_progress
Patch Set: Created 7 years, 2 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 | googletest/trace_test_cases.py » ('j') | tools/isolateserver_load_test.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 """Runs each test cases as a single shard, single process execution. 6 """Runs each test cases as a single shard, single process execution.
7 7
8 Similar to sharding_supervisor.py but finer grained. It runs each test case 8 Similar to sharding_supervisor.py but finer grained. It runs each test case
9 individually instead of running per shard. Runs multiple instances in parallel. 9 individually instead of running per shard. Runs multiple instances in parallel.
10 """ 10 """
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 else: 857 else:
858 line = '%s %s' % (i['test_case'], duration) 858 line = '%s %s' % (i['test_case'], duration)
859 if self.verbose or not test_case_has_passed or try_count > 0: 859 if self.verbose or not test_case_has_passed or try_count > 0:
860 # Print output in one of three cases: 860 # Print output in one of three cases:
861 # - --verbose was specified. 861 # - --verbose was specified.
862 # - The test failed. 862 # - The test failed.
863 # - The wasn't the first attempt (this is needed so the test parser can 863 # - The wasn't the first attempt (this is needed so the test parser can
864 # detect that a test has been successfully retried). 864 # detect that a test has been successfully retried).
865 if i['output']: 865 if i['output']:
866 line += '\n' + i['output'] 866 line += '\n' + i['output']
867 self.progress.update_item(line, index=1, size=need_to_retry) 867 self.progress.update_item(line, col0=1, col1=need_to_retry)
868 868
869 if need_to_retry: 869 if need_to_retry:
870 priority = self._retry(priority, i['test_case'], try_count) 870 priority = self._retry(priority, i['test_case'], try_count)
871 871
872 # Delay yielding when only one test case is running, in case of a 872 # Delay yielding when only one test case is running, in case of a
873 # crash-after-succeed. 873 # crash-after-succeed.
874 if len(test_cases) > 1: 874 if len(test_cases) > 1:
875 yield i 875 yield i
876 876
877 if proc.returncode and not got_failure_at_least_once: 877 if proc.returncode and not got_failure_at_least_once:
878 if results and len(test_cases) == 1: 878 if results and len(test_cases) == 1:
879 # Crash after pass. 879 # Crash after pass.
880 results[-1]['returncode'] = proc.returncode 880 results[-1]['returncode'] = proc.returncode
881 881
882 if try_count < self.retries: 882 if try_count < self.retries:
883 # This is tricky, one of the test case failed but each did print that 883 # This is tricky, one of the test case failed but each did print that
884 # they succeeded! Retry them *all* individually. 884 # they succeeded! Retry them *all* individually.
885 if not self.verbose and not try_count: 885 if not self.verbose and not try_count:
886 # Print all the output as one shot when not verbose to be sure the 886 # Print all the output as one shot when not verbose to be sure the
887 # potential stack trace is printed. 887 # potential stack trace is printed.
888 output = ''.join(i['output'] for i in results) 888 output = ''.join(i['output'] for i in results)
889 self.progress.update_item(output, raw=True) 889 self.progress.update_item(output, raw=True)
890 for i in results: 890 for i in results:
891 priority = self._retry(priority, i['test_case'], try_count) 891 priority = self._retry(priority, i['test_case'], try_count)
892 self.progress.update_item('', size=1) 892 self.progress.update_item('', col1=1)
893 893
894 # Only yield once the process completed when there is only one test case as 894 # Only yield once the process completed when there is only one test case as
895 # a safety precaution. 895 # a safety precaution.
896 if results and len(test_cases) == 1: 896 if results and len(test_cases) == 1:
897 yield results[-1] 897 yield results[-1]
898 898
899 def _retry(self, priority, test_case, try_count): 899 def _retry(self, priority, test_case, try_count):
900 """Adds back the same task again only if relevant. 900 """Adds back the same task again only if relevant.
901 901
902 It may add it either at lower (e.g. higher value) priority or at the end of 902 It may add it either at lower (e.g. higher value) priority or at the end of
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 if not clusters: 1175 if not clusters:
1176 clusters = calc_cluster_default(len(test_cases), jobs) 1176 clusters = calc_cluster_default(len(test_cases), jobs)
1177 else: 1177 else:
1178 # Limit the value. 1178 # Limit the value.
1179 clusters = max(min(clusters, len(test_cases) / jobs), 1) 1179 clusters = max(min(clusters, len(test_cases) / jobs), 1)
1180 1180
1181 logging.debug('%d test cases with clusters of %d', len(test_cases), clusters) 1181 logging.debug('%d test cases with clusters of %d', len(test_cases), clusters)
1182 1182
1183 if gtest_output: 1183 if gtest_output:
1184 gtest_output = gen_gtest_output_dir(cwd, gtest_output) 1184 gtest_output = gen_gtest_output_dir(cwd, gtest_output)
1185 progress = threading_utils.Progress(len(test_cases)) 1185 progress = threading_utils.Progress([0, len(test_cases)])
1186 progress.use_cr_only = not no_cr 1186 progress.use_cr_only = not no_cr
1187 serial_tasks = threading_utils.QueueWithProgress(0) 1187 serial_tasks = threading_utils.QueueWithProgress(progress)
1188 serial_tasks.set_progress(progress)
1189 1188
1190 def add_serial_task(priority, func, *args, **kwargs): 1189 def add_serial_task(priority, func, *args, **kwargs):
1191 """Adds a serial task, to be executed later.""" 1190 """Adds a serial task, to be executed later."""
1192 assert isinstance(priority, int) 1191 assert isinstance(priority, int)
1193 assert callable(func) 1192 assert callable(func)
1194 serial_tasks.put((priority, func, args, kwargs)) 1193 serial_tasks.put((priority, func, args, kwargs))
1195 1194
1196 with threading_utils.ThreadPoolWithProgress( 1195 with threading_utils.ThreadPoolWithProgress(
1197 progress, jobs, jobs, len(test_cases)) as pool: 1196 progress, jobs, jobs, len(test_cases)) as pool:
1198 runner = ChromiumGoogleTestRunner( 1197 runner = ChromiumGoogleTestRunner(
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 options.gtest_output, 1598 options.gtest_output,
1600 result_file, 1599 result_file,
1601 options.verbose) 1600 options.verbose)
1602 except Failure as e: 1601 except Failure as e:
1603 print >> sys.stderr, e.args[0] 1602 print >> sys.stderr, e.args[0]
1604 return 1 1603 return 1
1605 1604
1606 1605
1607 if __name__ == '__main__': 1606 if __name__ == '__main__':
1608 sys.exit(main(sys.argv[1:])) 1607 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | googletest/trace_test_cases.py » ('j') | tools/isolateserver_load_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698