changeset 613:b4d32c0ab577

0.6dev: Fixing browse source coverage annotation. Also fixes tests (source paths starts with '/', reduces log amount, and tones down the red and green CSS styles. Closes #365.
author osimons
date Sat, 01 Aug 2009 02:36:53 +0000
parents ac6c6fbead45
children 0c96346efa29
files bitten/htdocs/bitten_coverage.css bitten/report/coverage.py
diffstat 2 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/htdocs/bitten_coverage.css
+++ b/bitten/htdocs/bitten_coverage.css
@@ -1,4 +1,4 @@
 /* Code coverage file annotations */
 table.code th.coverage { width: 4em; }
-table.code th.covered { background-color: #0f0; }
-table.code th.uncovered { background-color: #f00; }
+table.code th.covered { background-color: #6F6; }
+table.code th.uncovered { background-color: #f66; }
--- a/bitten/report/coverage.py
+++ b/bitten/report/coverage.py
@@ -147,12 +147,12 @@
         >>> req = Mock(href=Href('/'), perm=MockPerm(), chrome={})
 
         Version in the branch should not match:
-        >>> context = Context.from_request(req, 'source', 'branches/blah/foo.py', 123)
+        >>> context = Context.from_request(req, 'source', '/branches/blah/foo.py', 123)
         >>> ann.get_annotation_data(context)
         []
 
         Version in the trunk should match:
-        >>> context = Context.from_request(req, 'source', 'trunk/foo.py', 123)
+        >>> context = Context.from_request(req, 'source', '/trunk/foo.py', 123)
         >>> data = ann.get_annotation_data(context)
         >>> print data
         [u'5', u'-', u'0']
@@ -184,20 +184,23 @@
             reports = []
             for build in builds:
                 config = BuildConfig.fetch(self.env, build.config)
-                if not resource.id.startswith(config.path):
+                if not resource.id.startswith('/' + config.path.lstrip('/')):
                     continue
                 reports = Report.select(self.env, build=build.id,
                                         category='coverage')
-                path_in_config = resource.id[len(config.path):].lstrip('/')
+                path_in_config = resource.id[len(config.path)+1:].lstrip('/')
                 for report in reports:
                     for item in report.items:
                         if item.get('file') == path_in_config:
-                            # TODO should aggregate coverage across builds
-                            return item.get('line_hits', '').split()
+                            coverage = item.get('line_hits', '').split()
+                            if coverage:
+                                # Return first result with line data
+                                self.log.debug("Coverage annotate for %s: %s" \
+                                            % (resource.id, coverage))
+                                return coverage
             return []
 
         def annotate_row(self, context, row, lineno, line, data):
-            self.log.debug('%s', data)
             from genshi.builder import tag
             lineno -= 1 # 0-based index for data
             if lineno >= len(data):
Copyright (C) 2012-2017 Edgewall Software