summaryrefslogtreecommitdiffstats
path: root/tools/code_coverage
diff options
context:
space:
mode:
authorlliabraa@google.com <lliabraa@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-13 20:56:47 +0000
committerlliabraa@google.com <lliabraa@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-13 20:56:47 +0000
commit3d50be7a85896f79f54fd95f384563830f440e62 (patch)
treedeb556d1f7b0228bfaf0366952e9e20c9311f000 /tools/code_coverage
parent94eee3b79d961347a4e9219f4385ab6d24bec707 (diff)
downloadchromium_src-3d50be7a85896f79f54fd95f384563830f440e62.zip
chromium_src-3d50be7a85896f79f54fd95f384563830f440e62.tar.gz
chromium_src-3d50be7a85896f79f54fd95f384563830f440e62.tar.bz2
Adds a --base_url argument to croc.py for adding a <base> tag in HTML output.
If a base_url is specified on the command line, each HTML output file will contain an HTML <base> tag with an HREF that consists of the base_url and the output file's relative path with in the HTML output hierarchy. This ensures that relative URLs in the HTML output files will point to the correct location on servers that redirect/mangle URLs. The href of the HTML <link> tag pointing to croc.ss is also prepended with the value of base_url. BUG=None TEST=None Review URL: http://codereview.chromium.org/9134013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117691 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/code_coverage')
-rwxr-xr-xtools/code_coverage/croc.py7
-rw-r--r--tools/code_coverage/croc_html.py19
2 files changed, 19 insertions, 7 deletions
diff --git a/tools/code_coverage/croc.py b/tools/code_coverage/croc.py
index 770e7f5..1b9908a 100755
--- a/tools/code_coverage/croc.py
+++ b/tools/code_coverage/croc.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -646,6 +646,9 @@ def Main(argv):
parser.add_option(
'-m', '--html', dest='html_out', type='string', metavar='PATH',
help='write HTML output to PATH')
+ parser.add_option(
+ '-b', '--base_url', dest='base_url', type='string', metavar='URL',
+ help='include URL in base tag of HTML output')
parser.set_defaults(
inputs=[],
@@ -708,7 +711,7 @@ def Main(argv):
# Generate HTML
if options.html_out:
- html = croc_html.CrocHtml(cov, options.html_out)
+ html = croc_html.CrocHtml(cov, options.html_out, options.base_url)
html.Write()
# Normal exit
diff --git a/tools/code_coverage/croc_html.py b/tools/code_coverage/croc_html.py
index 0e07a5a..929ecf6 100644
--- a/tools/code_coverage/croc_html.py
+++ b/tools/code_coverage/croc_html.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -113,10 +113,11 @@ COV_TYPE_CLASS = {None: 'missing', 0: 'instr', 1: 'covered', 2: ''}
class CrocHtml(object):
"""Crocodile HTML output class."""
- def __init__(self, cov, output_root):
+ def __init__(self, cov, output_root, base_url=None):
"""Constructor."""
self.cov = cov
self.output_root = output_root
+ self.base_url = base_url
self.xml_impl = xml.dom.getDOMImplementation()
self.time_string = 'Coverage information generated %s.' % time.asctime()
@@ -133,9 +134,17 @@ class CrocHtml(object):
f = HtmlFile(self.xml_impl, self.output_root + '/' + filename)
f.head.E('title').Text(title)
- f.head.E(
- 'link', rel='stylesheet', type='text/css',
- href='../' * (len(filename.split('/')) - 1) + 'croc.css')
+
+ if self.base_url:
+ css_href = self.base_url + 'croc.css'
+ base_href = self.base_url + os.path.dirname(filename)
+ if not base_href.endswith('/'):
+ base_href += '/'
+ f.head.E('base', href=base_href)
+ else:
+ css_href = '../' * (len(filename.split('/')) - 1) + 'croc.css'
+
+ f.head.E('link', rel='stylesheet', type='text/css', href=css_href)
return f