OLD | NEW |
---|---|
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 Loading... | |
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=True, size=need_to_retry) | 867 self.progress.update_item(line, index=1, size=need_to_retry) |
Vadim Sh.
2013/10/02 18:19:48
int(need_to_retry)?
Marc-Antoine Ruel (Google)
2013/10/02 19:41:26
Done.
| |
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=True) | 892 self.progress.update_item('', size=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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1599 options.gtest_output, | 1599 options.gtest_output, |
1600 result_file, | 1600 result_file, |
1601 options.verbose) | 1601 options.verbose) |
1602 except Failure as e: | 1602 except Failure as e: |
1603 print >> sys.stderr, e.args[0] | 1603 print >> sys.stderr, e.args[0] |
1604 return 1 | 1604 return 1 |
1605 | 1605 |
1606 | 1606 |
1607 if __name__ == '__main__': | 1607 if __name__ == '__main__': |
1608 sys.exit(main(sys.argv[1:])) | 1608 sys.exit(main(sys.argv[1:])) |
OLD | NEW |