From 1294535b8f2f0af706bae047e6c4393bb2dea1f1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 3 Nov 2011 00:31:13 +0000 Subject: [PATCH] Issue 2014: Improve HTML output of regression tests - Use Javascript to enable filtering of table rows by type - Make sure git file compare cell contents are HTML-escaped - Fix some HTML validation issues --- scripts/build/output-distance.py | 65 +++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 13 deletions(-) mode change 100644 => 100755 scripts/build/output-distance.py diff --git a/scripts/build/output-distance.py b/scripts/build/output-distance.py old mode 100644 new mode 100755 index b90bda5548..d2d55d77fa --- a/scripts/build/output-distance.py +++ b/scripts/build/output-distance.py @@ -5,6 +5,8 @@ import os import math import re +import cgi + ## so we can call directly as scripts/build/output-distance.py me_path = os.path.abspath (os.path.split (sys.argv[0])[0]) sys.path.insert (0, me_path + '/../python/') @@ -457,7 +459,7 @@ class GitFileCompareLink (FileCompareLink): str = '\n'.join ([l[:80] for l in str.split ('\n')]) - str = '
%s
' % str + str = '
%s
' % cgi.escape (str) return str def calc_distance (self): @@ -942,33 +944,70 @@ class ComparisonData: (changed, below, unchanged) = self.thresholded_results (threshold) - html = '' + table_rows = '' old_prefix = os.path.split (dir1)[1] for link in changed: - html += link.html_record_string (dest_dir) + table_rows += link.html_record_string (dest_dir) short_dir1 = shorten_string (dir1) short_dir2 = shorten_string (dir2) + + summary = '' + below_count = len (below) + + if below_count: + summary += '

%d below threshold

' % below_count + + summary += '

%d unchanged

' % len (unchanged) + html = ''' + +LilyPond regression test results + + + +

+ click to filter rows by type: + ly / + profiling / + signature / + midi / + log / + gittxt / + reset to all +

+ +
+ +%(summary)s + +
+ -%(html)s +%(table_rows)s
distance %(short_dir1)s %(short_dir2)s
+ ''' % locals() - html += ('

') - below_count = len (below) - - if below_count: - html += ('

%d below threshold

' % below_count) - - html += ('

%d unchanged

' % len (unchanged)) - dest_file = dest_dir + '/index.html' open_write_file (dest_file).write (html) @@ -1262,7 +1301,7 @@ def main (): run_tests () sys.exit (0) - if len (args) % 2: + if len (args) % 2 == 1: p.print_usage () sys.exit (2) -- 2.39.5