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

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

Issue 307032: Fix coverage on the Mac. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/chrome.gyp ('k') | 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) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2009 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 18 matching lines...) Expand all
29 --genhtml: generate html output. If not specified only lcov is generated. 29 --genhtml: generate html output. If not specified only lcov is generated.
30 30
31 --all_unittests: if present, run all files named *_unittests that we 31 --all_unittests: if present, run all files named *_unittests that we
32 can find. 32 can find.
33 33
34 --fast_test: make the tests run real fast (just for testing) 34 --fast_test: make the tests run real fast (just for testing)
35 35
36 --strict: if a test fails, we continue happily. --strict will cause 36 --strict: if a test fails, we continue happily. --strict will cause
37 us to die immediately. 37 us to die immediately.
38 38
39 --trim=False: by default we trim away tests known to be problematic on
40 specific platforms. If set to false we do NOT trim out tests.
41
39 Strings after all options are considered tests to run. Test names 42 Strings after all options are considered tests to run. Test names
40 have all text before a ':' stripped to help with gyp compatibility. 43 have all text before a ':' stripped to help with gyp compatibility.
41 For example, ../base/base.gyp:base_unittests is interpreted as a test 44 For example, ../base/base.gyp:base_unittests is interpreted as a test
42 named "base_unittests". 45 named "base_unittests".
43 """ 46 """
44 47
45 import glob 48 import glob
46 import logging 49 import logging
47 import optparse 50 import optparse
48 import os 51 import os
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 131
129 # If needed, append .exe to tests since vsinstr.exe likes it that 132 # If needed, append .exe to tests since vsinstr.exe likes it that
130 # way. 133 # way.
131 if self.IsWindows(): 134 if self.IsWindows():
132 for ind in range(len(self.tests)): 135 for ind in range(len(self.tests)):
133 test = self.tests[ind] 136 test = self.tests[ind]
134 test_exe = test + '.exe' 137 test_exe = test + '.exe'
135 if not test.endswith('.exe') and os.path.exists(test_exe): 138 if not test.endswith('.exe') and os.path.exists(test_exe):
136 self.tests[ind] = test_exe 139 self.tests[ind] = test_exe
137 140
138 # Temporarily make Windows quick for bringup by filtering 141 def TrimTests(self):
139 # out all except base_unittests. Easier than a chrome.cyp change. 142 """Trim specific tests for each platform."""
140 # TODO(jrg): remove this
141 if self.IsWindows(): 143 if self.IsWindows():
142 t2 = [] 144 # special case for now to be fast
145 inclusion = ['base_unittests']
146 keep = []
143 for test in self.tests: 147 for test in self.tests:
144 if 'base_unittests' in test: 148 for i in inclusion:
145 t2.append(test) 149 if test.endswith(i):
146 self.tests = t2 150 keep.append(test)
147 151 self.tests = keep
148 152 return
153 if self.IsLinux():
154 return
155 if self.IsMac():
156 exclusion = ['automated_ui_tests']
157 punted = []
158 for test in self.tests:
159 for e in exclusion:
160 if test.endswith(e):
161 punted.append(test)
162 self.tests = filter(lambda t: t not in punted, self.tests)
163 if punted:
164 logging.info('Tests trimmed out: ' + str(punted))
149 165
150 def ConfirmPlatformAndPaths(self): 166 def ConfirmPlatformAndPaths(self):
151 """Confirm OS and paths (e.g. lcov).""" 167 """Confirm OS and paths (e.g. lcov)."""
152 for program in self.programs: 168 for program in self.programs:
153 if not os.path.exists(program): 169 if not os.path.exists(program):
154 logging.fatal('Program missing: ' + program) 170 logging.fatal('Program missing: ' + program)
155 sys.exit(1) 171 sys.exit(1)
156 172
157 def Run(self, cmdlist, ignore_error=False, ignore_retcode=None, 173 def Run(self, cmdlist, ignore_error=False, ignore_retcode=None,
158 explanation=None): 174 explanation=None):
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 parser.add_option('-s', 343 parser.add_option('-s',
328 '--strict', 344 '--strict',
329 dest='strict', 345 dest='strict',
330 default=False, 346 default=False,
331 help='Be strict and die on test failure.') 347 help='Be strict and die on test failure.')
332 parser.add_option('-S', 348 parser.add_option('-S',
333 '--src_root', 349 '--src_root',
334 dest='src_root', 350 dest='src_root',
335 default='.', 351 default='.',
336 help='Source root (only used on Windows)') 352 help='Source root (only used on Windows)')
353 parser.add_option('-t',
354 '--trim',
355 dest='trim',
356 default=True,
357 help='Trim out tests? Default True.')
337 (options, args) = parser.parse_args() 358 (options, args) = parser.parse_args()
338 if not options.directory: 359 if not options.directory:
339 parser.error('Directory not specified') 360 parser.error('Directory not specified')
340 coverage = Coverage(options.directory, options, args) 361 coverage = Coverage(options.directory, options, args)
341 coverage.ClearData() 362 coverage.ClearData()
342 coverage.FindTests() 363 coverage.FindTests()
364 if options.trim:
365 coverage.TrimTests()
343 coverage.BeforeRunTests() 366 coverage.BeforeRunTests()
344 coverage.RunTests() 367 coverage.RunTests()
345 coverage.AfterRunTests() 368 coverage.AfterRunTests()
346 coverage.GenerateLcov() 369 coverage.GenerateLcov()
347 if options.genhtml: 370 if options.genhtml:
348 coverage.GenerateHtml() 371 coverage.GenerateHtml()
349 return 0 372 return 0
350 373
351 374
352 if __name__ == '__main__': 375 if __name__ == '__main__':
353 sys.exit(main()) 376 sys.exit(main())
OLDNEW
« no previous file with comments | « chrome/chrome.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698