diff options
-rw-r--r-- | CHANGES.txt | 3 | ||||
-rw-r--r-- | coverage/html.py | 35 | ||||
-rw-r--r-- | coverage/htmlfiles/style.css | 1 | ||||
-rw-r--r-- | tests/farm/html/run_b_branch.py | 6 |
4 files changed, 29 insertions, 16 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index a45ed98e..5d66825f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -35,6 +35,9 @@ Version 4.0b1 --- 2 August 2015 Peak. This is not a part of the Cobertura DTD, so the XML report no longer references the DTD. +- Missing branches in the HTML report now have a bit more information in the + right-hand annotations. Hopefully this will make their meaning clearer. + - All the reporting functions now behave the same if no data had been collected, exiting with a status code of 1. Fixed ``fail_under`` to be applied even when the report is empty. Thanks, Ionel Cristian Mărieș. diff --git a/coverage/html.py b/coverage/html.py index 9022ac4f..7c4dbc0d 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -201,21 +201,32 @@ class HtmlReporter(Reporter): line_class.append(c_mis) elif self.arcs and lineno in missing_branch_arcs: line_class.append(c_par) - annlines = [] + shorts = [] + longs = [] for b in missing_branch_arcs[lineno]: if b < 0: - annlines.append("exit") + shorts.append("exit") + longs.append("the function exit") else: - annlines.append(str(b)) - annotate_html = " ".join(annlines) - if len(annlines) > 1: - annotate_title = "no jumps to these line numbers" - elif len(annlines) == 1: - annotate_title = "no jump to this line number" + shorts.append(b) + longs.append("line %d" % b) + # 202F is NARROW NO-BREAK SPACE. + # 219B is RIGHTWARDS ARROW WITH STROKE. + short_fmt = "%s ↛ %s" + annotate_html = ", ".join(short_fmt % (lineno, d) for d in shorts) + annotate_html += " [?]" + + annotate_title = "Line %d was executed, but never jumped to " % lineno + if len(longs) == 1: + annotate_title += longs[0] + elif len(long) == 2: + annotate_title += longs[0] + " or " + longs[1] + else: + annotate_title += ", ".join(longs[:-1]) + ", or " + longs[-1] elif lineno in analysis.statements: line_class.append(c_run) - # Build the HTML for the line + # Build the HTML for the line. html = [] for tok_type, tok_text in line: if tok_type == "ws": @@ -292,11 +303,11 @@ class HtmlStatus(object): # # { # 'format': 1, - # 'settings': '\x87\x9cc8\x80\xe5\x97\xb16\xfcv\xa2\x8d\x8a\xbb\xcf', + # 'settings': '540ee119c15d52a68a53fe6f0897346d', # 'version': '4.0a1', # 'files': { # 'cogapp___init__': { - # 'hash': '\x99*\x0e\\\x10\x11O\x06WG/gJ\x83\xdd\x99', + # 'hash': 'e45581a5b48f879f301c0f30bf77a50c', # 'index': { # 'html_filename': 'cogapp___init__.html', # 'name': 'cogapp/__init__', @@ -305,7 +316,7 @@ class HtmlStatus(object): # }, # ... # 'cogapp_whiteutils': { - # 'hash': 'o\xfd\x0e+s2="\xb2\x1c\xd6\xa1\xee\x85\x85\xda', + # 'hash': '8504bb427fc488c4176809ded0277d51', # 'index': { # 'html_filename': 'cogapp_whiteutils.html', # 'name': 'cogapp/whiteutils', diff --git a/coverage/htmlfiles/style.css b/coverage/htmlfiles/style.css index 2dfb8f65..15b08904 100644 --- a/coverage/htmlfiles/style.css +++ b/coverage/htmlfiles/style.css @@ -252,7 +252,6 @@ td.text { .text span.annotate { font-family: georgia; - font-style: italic; color: #666; float: right; padding-right: .5em; diff --git a/tests/farm/html/run_b_branch.py b/tests/farm/html/run_b_branch.py index 2451f069..382e3110 100644 --- a/tests/farm/html/run_b_branch.py +++ b/tests/farm/html/run_b_branch.py @@ -19,9 +19,9 @@ contains("html_b_branch/b_py.html", '<span class="key">if</span> <span class="nam">x</span> <span class="op"><</span> <span class="num">2</span>', ' <span class="nam">a</span> <span class="op">=</span> <span class="num">3</span>', '<span class="pc_cov">70%</span>', - '<span class="annotate" title="no jump to this line number">11</span>', - '<span class="annotate" title="no jump to this line number">exit</span>', - '<span class="annotate" title="no jumps to these line numbers">26 28</span>', + '<span class="annotate" title="Line 8 was executed, but never jumped to line 11">8 ↛ 11 [?]</span>', + '<span class="annotate" title="Line 17 was executed, but never jumped to the function exit">17 ↛ exit [?]</span>', + '<span class="annotate" title="Line 25 was executed, but never jumped to line 26 or line 28">25 ↛ 26, 25 ↛ 28 [?]</span>', ) contains("html_b_branch/index.html", '<a href="b_py.html">b.py</a>', |