diff options
Diffstat (limited to 'tools/code_coverage')
-rwxr-xr-x | tools/code_coverage/croc.py | 7 | ||||
-rw-r--r-- | tools/code_coverage/croc_html.py | 19 |
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 |