# HG changeset patch # User osimons # Date 1249094213 0 # Node ID b4d32c0ab577610e40717b1459ae5ac42303449e # Parent ac6c6fbead45d2901873dc20fb5939e28e4559dd 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. diff --git a/bitten/htdocs/bitten_coverage.css b/bitten/htdocs/bitten_coverage.css --- 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; } diff --git a/bitten/report/coverage.py b/bitten/report/coverage.py --- 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):