diff options
author | Robert Brewer <fumanchu@aminus.org> | 2005-08-25 08:37:16 +0000 |
---|---|---|
committer | Robert Brewer <fumanchu@aminus.org> | 2005-08-25 08:37:16 +0000 |
commit | 596b1f603047a407bf8949b018671c7de13e9f2f (patch) | |
tree | 87789f65f6dd70e6f541afec47515e1f6fe7c560 /cherrypy/lib/covercp.py | |
parent | f80f80522f35af16460af500914c427d4f5ed344 (diff) | |
download | cherrypy-git-596b1f603047a407bf8949b018671c7de13e9f2f.tar.gz |
Improved covercp's annotated file output: blank lines have been reinstated, but blank or other non-statement lines are marked "not covered" if the next valid statement line is marked "not covered".
Diffstat (limited to 'cherrypy/lib/covercp.py')
-rw-r--r-- | cherrypy/lib/covercp.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/cherrypy/lib/covercp.py b/cherrypy/lib/covercp.py index 7f56e34c..7d15e66e 100644 --- a/cherrypy/lib/covercp.py +++ b/cherrypy/lib/covercp.py @@ -284,7 +284,6 @@ def get_tree(base, exclude): for path in runs: if not _skip_file(path, exclude) and not os.path.isdir(path): _graft(path, tree) - print tree return tree class CoverStats(object): @@ -330,23 +329,25 @@ class CoverStats(object): def annotated_file(self, filename, statements, excluded, missing): source = open(filename, 'r') - lineno = 0 - while 1: - line = source.readline() - if line == '': - break - line = line[:-1] - lineno = lineno + 1 - if line == '': - yield ' ' - continue + buffer = [] + for lineno, line in enumerate(source.readlines()): + lineno += 1 + line = line.strip("\n\r") + empty_the_buffer = True if lineno in excluded: template = TEMPLATE_LOC_EXCLUDED elif lineno in missing: template = TEMPLATE_LOC_NOT_COVERED - else: + elif lineno in statements: template = TEMPLATE_LOC_COVERED - yield template % (lineno, cgi.escape(line)) + else: + empty_the_buffer = False + buffer.append((lineno, line)) + if empty_the_buffer: + for lno, pastline in buffer: + yield template % (lno, cgi.escape(pastline)) + buffer = [] + yield template % (lineno, cgi.escape(line)) def report(self, name): coverage.get_ready() |