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

Side by Side Diff: run_test_cases.py

Issue 12218018: Fix --gtest_output=xml: support. (Closed) Base URL: https://git.chromium.org/chromium/tools/swarm_client.git@master
Patch Set: typo Created 7 years, 10 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 | tests/gtest_fake/gtest_fake_xml.py » ('j') | 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 else: 759 else:
760 # If 10% of test cases fail, just too bad. 760 # If 10% of test cases fail, just too bad.
761 decider = RunSome(len(test_cases), retries, 2, 0.1, max_failures) 761 decider = RunSome(len(test_cases), retries, 2, 0.1, max_failures)
762 762
763 tempdir = None 763 tempdir = None
764 try: 764 try:
765 if gtest_output: 765 if gtest_output:
766 if gtest_output.startswith('xml'): 766 if gtest_output.startswith('xml'):
767 # Have each shard write an XML file and them merge them all. 767 # Have each shard write an XML file and them merge them all.
768 tempdir = tempfile.mkdtemp(prefix='run_test_cases') 768 tempdir = tempfile.mkdtemp(prefix='run_test_cases')
769 cmd.append('--gtest_output=xml:' + tempdir) 769 # The real google-test requires a trailing os.path.sep when a directory
770 # is used.
771 cmd.append('--gtest_output=xml:' + tempdir + os.path.sep)
770 # Figure out the result filepath in case we can't parse it, it'd be 772 # Figure out the result filepath in case we can't parse it, it'd be
771 # annoying to error out after running the tests. 773 # annoying to error out after running the tests.
772 if gtest_output == 'xml': 774 if gtest_output == 'xml':
773 gtest_output = os.path.join(cwd, 'test_detail.xml') 775 gtest_output = os.path.join(cwd, 'test_detail.xml')
774 else: 776 else:
775 match = re.match(r'xml\:(.+)', gtest_output) 777 match = re.match(r'xml\:(.+)', gtest_output)
776 if not match: 778 if not match:
777 print >> sys.stderr, 'Can\'t parse --gtest_output=%s' % gtest_output 779 print >> sys.stderr, 'Can\'t parse --gtest_output=%s' % gtest_output
778 return 1 780 return 1
779 gtest_output = os.path.join(cwd, match.group(1)) 781 gtest_output = os.path.join(cwd, match.group(1))
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 if result: 830 if result:
829 base_path = os.path.dirname(gtest_output) 831 base_path = os.path.dirname(gtest_output)
830 if base_path and not os.path.isdir(base_path): 832 if base_path and not os.path.isdir(base_path):
831 os.makedirs(base_path) 833 os.makedirs(base_path)
832 if os.path.isdir(gtest_output): 834 if os.path.isdir(gtest_output):
833 # Includes compatibility with with google-test when a directory is 835 # Includes compatibility with with google-test when a directory is
834 # specified. 836 # specified.
835 # TODO(maruel): It would automatically add 0, 1, 2 when a previous 837 # TODO(maruel): It would automatically add 0, 1, 2 when a previous
836 # one exists. 838 # one exists.
837 gtest_output = os.path.join(gtest_output, 'test_detail.xml') 839 gtest_output = os.path.join(gtest_output, 'test_detail.xml')
838 print('Saving gtest compatible XML file to: %s' % gtest_output) 840 sys.stdout.write(
841 '\nSaving gtest compatible XML file to: %s\n' % gtest_output)
839 with open(gtest_output, 'w') as f: 842 with open(gtest_output, 'w') as f:
840 result.writexml(f) 843 result.writexml(f)
841 else: 844 else:
842 logging.error('Didn\'t find any XML file to write to %s' % gtest_output) 845 logging.error('Didn\'t find any XML file to write to %s' % gtest_output)
843 finally: 846 finally:
844 if tempdir: 847 if tempdir:
845 shutil.rmtree(tempdir) 848 shutil.rmtree(tempdir)
846 849
847 cleaned = {} 850 cleaned = {}
848 for item in results: 851 for item in results:
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 options.run_all, 1174 options.run_all,
1172 options.max_failures, 1175 options.max_failures,
1173 options.no_cr, 1176 options.no_cr,
1174 options.gtest_output, 1177 options.gtest_output,
1175 result_file, 1178 result_file,
1176 options.verbose) 1179 options.verbose)
1177 1180
1178 1181
1179 if __name__ == '__main__': 1182 if __name__ == '__main__':
1180 sys.exit(main(sys.argv[1:])) 1183 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | tests/gtest_fake/gtest_fake_xml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698