[benchmark] ReportFormatter: better inline headers

Improve inline headers in `single_table` mode to also print labels for the numeric columns.

Sections in the `single_table` are visually distinguished by a separator row preceding the the inline headers.

Separated header label styles for git and markdown modes with UPPERCASE and **Bold**  formatting respectively.

Inlined section template definitions.
This commit is contained in:
Pavol Vaskovic
2019-05-23 23:24:51 +02:00
parent 73b31006ee
commit b3f7996ea7
2 changed files with 50 additions and 30 deletions

View File

@@ -857,15 +857,33 @@ class TestReportFormatter(OldAndNewLog):
def test_single_table_report(self):
"""Single table report has bold inline headers and no sections."""
self.tc.removed = [] # test handling empty section
rf = ReportFormatter(self.tc, changes_only=True, single_table=True)
markdown = rf.markdown()
self.assertNotIn('<details', markdown)
self.assertNotIn('<details', markdown) # no sections
self.assertNotIn('\n\n', markdown) # table must not be broken
self.assertNotIn('Removed', markdown)
self.assert_report_contains([
'**Regression**', '**Added**',
'| OLD', '| NEW', '| DELTA', '| RATIO'
'\n**Regression** ',
'| **OLD**', '| **NEW**', '| **DELTA**', '| **RATIO**',
'\n**Added** ',
'| **MIN**', '| **MAX**', '| **MEAN**', '| **MAX_RSS**'
], markdown)
# Single delimiter row:
self.assertIn('\n:---', markdown) # first column is left aligned
self.assertEqual(markdown.count('| ---:'), 4) # other, right aligned
# Separator before every inline header (new section):
self.assertEqual(markdown.count('&nbsp; | | | | '), 2)
git = rf.git()
self.assertNotIn('): \n', git) # no sections
self.assertNotIn('REMOVED', git)
self.assert_report_contains([
'\nREGRESSION ', ' OLD ', ' NEW ', ' DELTA ', ' RATIO ',
'\n\nADDED ', ' MIN ', ' MAX ', ' MEAN ', ' MAX_RSS '
], git)
# Separator before every inline header (new section):
self.assertEqual(git.count('\n\n'), 2)
class Test_parse_args(unittest.TestCase):