summaryrefslogtreecommitdiffstats
path: root/tools/code_coverage
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-05 01:05:10 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-05 01:05:10 +0000
commitff85ad39218c91338a7ab07dde8f8b8d98842047 (patch)
tree3f9063aa69cbdb941be39c66d0fdbf44864b6637 /tools/code_coverage
parentc813f5bb08d815f3f8495bdb4962c9228235b0f8 (diff)
downloadchromium_src-ff85ad39218c91338a7ab07dde8f8b8d98842047.zip
chromium_src-ff85ad39218c91338a7ab07dde8f8b8d98842047.tar.gz
chromium_src-ff85ad39218c91338a7ab07dde8f8b8d98842047.tar.bz2
Correct mcov execution cwd so it works from either makefiles (target
coverage_run) or from buildbot. Kind of a hack but good enough for now. Make mcov path args into abs paths. Die with non-zero error code if coverage.info file not generated for clearer failure in buildbot. Review URL: http://codereview.chromium.org/2639005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48992 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/code_coverage')
-rwxr-xr-xtools/code_coverage/coverage_posix.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/tools/code_coverage/coverage_posix.py b/tools/code_coverage/coverage_posix.py
index ebc7df5..9f941dc 100755
--- a/tools/code_coverage/coverage_posix.py
+++ b/tools/code_coverage/coverage_posix.py
@@ -649,16 +649,30 @@ class Coverage(object):
def GenerateLcovPosix(self):
"""Convert profile data to lcov on Mac or Linux."""
+ start_dir = os.getcwd()
if self.IsLinux():
- # With Linux/make the current directory for this command is
- # .../src/chrome but we need to be in .../src for the relative
- # path of source files to be correct. On Mac source files are
- # compiled with abs paths so this isn't a problem.
- start_dir = os.getcwd()
- os.chdir('..')
+ # With Linux/make (e.g. the coverage_run target), the current
+ # directory for this command is .../build/src/chrome but we need
+ # to be in .../build/src for the relative path of source files
+ # to be correct. However, when run from buildbot, the current
+ # directory is .../build. Accommodate.
+ # On Mac source files are compiled with abs paths so this isn't
+ # a problem.
+ # This is a bit of a hack. The best answer is to require this
+ # script be run in a specific directory for all cases (from
+ # Makefile or from buildbot).
+ if start_dir.endswith('chrome'):
+ print 'coverage_posix.py: doing a "cd .." to accomodate Linux/make PWD'
+ os.chdir('..')
+ elif start_dir.endswith('build'):
+ print 'coverage_posix.py: doing a "cd src" to accomodate buildbot PWD'
+ os.chdir('src')
+
command = [self.mcov,
- '--directory', self.directory_parent,
- '--output', self.coverage_info_file]
+ '--directory',
+ os.path.join(start_dir, self.directory_parent),
+ '--output',
+ os.path.join(start_dir, self.coverage_info_file)]
logging.info('Assembly command: ' + ' '.join(command))
retcode = subprocess.call(command)
if retcode:
@@ -668,6 +682,10 @@ class Coverage(object):
sys.exit(retcode)
if self.IsLinux():
os.chdir(start_dir)
+ if not os.path.exists(self.coverage_info_file):
+ logging.fatal('%s was not created. Coverage run failed.' %
+ self.coverage_info_file)
+ sys.exit(1)
def GenerateLcovWindows(self, testname=None):
"""Convert VSTS format to lcov. Appends coverage data to sum file."""