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

Side by Side Diff: tools/code_coverage/coverage_posix.py

Issue 11274053: Store coverage.info file in separate folders based on commandline parameters to coverage_posix.py. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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/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 """Generate and process code coverage. 6 """Generate and process code coverage.
7 7
8 TODO(jrg): rename this from coverage_posix.py to coverage_all.py! 8 TODO(jrg): rename this from coverage_posix.py to coverage_all.py!
9 9
10 Written for and tested on Mac, Linux, and Windows. To use this script 10 Written for and tested on Mac, Linux, and Windows. To use this script
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 print 'Clearing of coverage data NOT performed.' 755 print 'Clearing of coverage data NOT performed.'
756 return 756 return
757 print 'Clearing coverage data from previous runs.' 757 print 'Clearing coverage data from previous runs.'
758 if os.path.exists(self.coverage_info_file): 758 if os.path.exists(self.coverage_info_file):
759 os.remove(self.coverage_info_file) 759 os.remove(self.coverage_info_file)
760 if self.IsPosix(): 760 if self.IsPosix():
761 subprocess.call([self.lcov, 761 subprocess.call([self.lcov,
762 '--directory', self.directory_parent, 762 '--directory', self.directory_parent,
763 '--zerocounters']) 763 '--zerocounters'])
764 shutil.rmtree(os.path.join(self.directory, 'coverage')) 764 shutil.rmtree(os.path.join(self.directory, 'coverage'))
765 if self.options.all_unittests:
John Grabowski 2012/10/30 21:29:05 consider an unconditional delete. It is unclear w
pshenoy 2012/10/30 22:11:13 coverage_posix.py is run twice now. First time run
John Grabowski 2012/10/30 22:17:11 ok
766 if os.path.exists(os.path.join(self.directory, 'unittests_coverage')):
767 shutil.rmtree(os.path.join(self.directory, 'unittests_coverage'))
768 else:
769 if os.path.exists(os.path.join(self.directory, 'total_coverage')):
770 shutil.rmtree(os.path.join(self.directory, 'total_coverage'))
765 771
766 def BeforeRunOneTest(self, testname): 772 def BeforeRunOneTest(self, testname):
767 """Do things before running each test.""" 773 """Do things before running each test."""
768 if not self.IsWindows(): 774 if not self.IsWindows():
769 return 775 return
770 # Stop old counters if needed 776 # Stop old counters if needed
771 cmdlist = [self.perf, '-shutdown'] 777 cmdlist = [self.perf, '-shutdown']
772 self.Run(cmdlist, ignore_error=True) 778 self.Run(cmdlist, ignore_error=True)
773 # Instrument binaries 779 # Instrument binaries
774 for fulltest in self.tests: 780 for fulltest in self.tests:
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 os.path.join(start_dir, self.coverage_info_file)] 990 os.path.join(start_dir, self.coverage_info_file)]
985 logging.info('Assembly command: ' + ' '.join(command)) 991 logging.info('Assembly command: ' + ' '.join(command))
986 retcode = subprocess.call(command) 992 retcode = subprocess.call(command)
987 if retcode: 993 if retcode:
988 logging.fatal('COVERAGE: %s failed; return code: %d' % 994 logging.fatal('COVERAGE: %s failed; return code: %d' %
989 (command[0], retcode)) 995 (command[0], retcode))
990 if self.options.strict: 996 if self.options.strict:
991 sys.exit(retcode) 997 sys.exit(retcode)
992 if self.IsLinux(): 998 if self.IsLinux():
993 os.chdir(start_dir) 999 os.chdir(start_dir)
1000
1001 # Copy the unittests coverage information to a different folder.
1002 if self.options.all_unittests:
John Grabowski 2012/10/30 21:29:05 make the conditional set a var called filename (ei
pshenoy 2012/11/05 17:59:31 I think this is related to the other comment above
John Grabowski 2012/11/06 18:04:05 Sort of, but it would be nice to be pithy. For ex
pshenoy 2012/11/06 19:05:41 Done.
1003 unittests_dir = os.path.join(self.directory, 'unittests_coverage')
1004 if not os.path.exists(unittests_dir):
1005 os.makedirs(unittests_dir)
1006 shutil.copyfile(self.coverage_info_file, os.path.join(unittests_dir,
1007 'coverage.info'))
1008 else:
1009 # Save the overall coverage information.
1010 overall_dir = os.path.join(self.directory, 'total_coverage')
1011 if not os.path.exists(overall_dir):
1012 os.makedirs(overall_dir)
1013 shutil.copyfile(self.coverage_info_file, os.path.join(overall_dir,
1014 'coverage.info'))
1015
994 if not os.path.exists(self.coverage_info_file): 1016 if not os.path.exists(self.coverage_info_file):
995 logging.fatal('%s was not created. Coverage run failed.' % 1017 logging.fatal('%s was not created. Coverage run failed.' %
996 self.coverage_info_file) 1018 self.coverage_info_file)
997 sys.exit(1) 1019 sys.exit(1)
998 1020
999 def GenerateLcovWindows(self, testname=None): 1021 def GenerateLcovWindows(self, testname=None):
1000 """Convert VSTS format to lcov. Appends coverage data to sum file.""" 1022 """Convert VSTS format to lcov. Appends coverage data to sum file."""
1001 lcov_file = self.vsts_output + '.lcov' 1023 lcov_file = self.vsts_output + '.lcov'
1002 if os.path.exists(lcov_file): 1024 if os.path.exists(lcov_file):
1003 os.remove(lcov_file) 1025 os.remove(lcov_file)
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 if options.trim: 1164 if options.trim:
1143 coverage.TrimTests() 1165 coverage.TrimTests()
1144 coverage.RunTests() 1166 coverage.RunTests()
1145 if options.genhtml: 1167 if options.genhtml:
1146 coverage.GenerateHtml() 1168 coverage.GenerateHtml()
1147 return 0 1169 return 0
1148 1170
1149 1171
1150 if __name__ == '__main__': 1172 if __name__ == '__main__':
1151 sys.exit(main()) 1173 sys.exit(main())
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