diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-16 18:51:14 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-16 18:51:14 +0000 |
commit | b2e197115d8e60e3ef389035ea099efdb7abb531 (patch) | |
tree | 0a30b94d33050360711c78c6a1e482cde27bae9c /tools/code_coverage/coverage_posix.py | |
parent | bff545e65a6767bbf860058d713d4cdea0501d74 (diff) | |
download | chromium_src-b2e197115d8e60e3ef389035ea099efdb7abb531.zip chromium_src-b2e197115d8e60e3ef389035ea099efdb7abb531.tar.gz chromium_src-b2e197115d8e60e3ef389035ea099efdb7abb531.tar.bz2 |
Restore previous dribbling-subprocess-output code for non-Windows.
(Windows code adds buffering when used on POSIX adding uncomfortable
delays in output). Windows code retained for use on Windows only.
Add command line flag --dont-clear-coverage-data to facilitate tester use. Workflow:
1. compile for coverage
2. run chrome and do whatever
3. Run coverage script by hand; e.g.
tools/code_coverage/coverage_posix.py --directory out/Debug --genhtml out/index.html --dont-clear-coverage-data
The coverage_posix.py tool otherwise deletes all coverage data when it
starts since it assumes it only wants coverage data generated by it's
subprocesses.
BUG=none
TEST=coverage bots stay green; Anantha happier.
Review URL: http://codereview.chromium.org/2870054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52713 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/code_coverage/coverage_posix.py')
-rwxr-xr-x | tools/code_coverage/coverage_posix.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/code_coverage/coverage_posix.py b/tools/code_coverage/coverage_posix.py index 09911db7..5218ced 100755 --- a/tools/code_coverage/coverage_posix.py +++ b/tools/code_coverage/coverage_posix.py @@ -79,6 +79,10 @@ Linux: using the MacOS 10.6 SDK. Use of --no_exclusions prevents the use of this exclusion list. +--dont-clear-coverage-data: Normally we clear coverage data from + previous runs. If this arg is used we do NOT clear the coverage + data. + Strings after all options are considered tests to run. Test names have all text before a ':' stripped to help with gyp compatibility. For example, ../base/base.gyp:base_unittests is interpreted as a test @@ -165,6 +169,12 @@ class RunProgramThread(threading.Thread): self._retcode = None def run(self): + if sys.platform in ('win32', 'cygwin'): + return self._run_windows() + else: + self._run_posix() + + def _run_windows(self): # We need to save stdout to a temporary file because of a bug on the # windows implementation of python which can deadlock while waiting # for the IO to complete while writing to the PIPE and the pipe waiting @@ -213,6 +223,26 @@ class RunProgramThread(threading.Thread): gChildPIDs.remove(self._process.pid) self._queue.put(RunProgramThread.DONE) + def _run_posix(self): + """No deadlock problem so use the simple answer. The windows solution + appears to add extra buffering which we don't want on other platforms.""" + self._process = subprocess.Popen(self._cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + gChildPIDs.append(self._process.pid) + try: + while True: + line = self._process.stdout.readline() + if not line: # EOF + break + print line, + self._queue.put(RunProgramThread.PROGRESS, True) + except IOError: + pass + # If we get here the process is done. + gChildPIDs.remove(self._process.pid) + self._queue.put(RunProgramThread.DONE) + def stop(self): self.kill() @@ -521,6 +551,10 @@ class Coverage(object): def ClearData(self): """Clear old gcda files and old coverage info files.""" + if self.options.dont_clear_coverage_data: + print 'Clearing of coverage data NOT performed.' + return + print 'Clearing coverage data from previous runs.' if os.path.exists(self.coverage_info_file): os.remove(self.coverage_info_file) if self.IsPosix(): @@ -838,6 +872,11 @@ def CoverageOptionParser(): dest='no_exclusions', default=None, help=('Disable the exclusion list.')) + parser.add_option('--dont-clear-coverage-data', + dest='dont_clear_coverage_data', + default=False, + action='store_true', + help=('Turn off clearing of cov data from a prev run')) return parser |