Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(982)

Side by Side Diff: scripts/build/output-distance.py

Issue 5342042: Improve HTML output of regression tests (Closed)
Patch Set: Created 13 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!@PYTHON@ 1 #!@PYTHON@
2 import sys 2 import sys
3 import optparse 3 import optparse
4 import os 4 import os
5 import math 5 import math
6 import re 6 import re
7 7
8 from cgi import escape
Julien Rioux 2011/11/07 15:53:49 Since the style within lilypond's python sources i
adam.spiers 2011/11/07 19:20:42 Done.
9
8 ## so we can call directly as scripts/build/output-distance.py 10 ## so we can call directly as scripts/build/output-distance.py
9 me_path = os.path.abspath (os.path.split (sys.argv[0])[0]) 11 me_path = os.path.abspath (os.path.split (sys.argv[0])[0])
10 sys.path.insert (0, me_path + '/../python/') 12 sys.path.insert (0, me_path + '/../python/')
11 sys.path.insert (0, me_path + '/../python/out/') 13 sys.path.insert (0, me_path + '/../python/out/')
12 14
13 15
14 X_AXIS = 0 16 X_AXIS = 0
15 Y_AXIS = 1 17 Y_AXIS = 1
16 INFTY = 1e6 18 INFTY = 1e6
17 19
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 452
451 453
452 class GitFileCompareLink (FileCompareLink): 454 class GitFileCompareLink (FileCompareLink):
453 def get_cell (self, oldnew): 455 def get_cell (self, oldnew):
454 str = self.contents[oldnew] 456 str = self.contents[oldnew]
455 457
456 # truncate long lines 458 # truncate long lines
457 str = '\n'.join ([l[:80] for l in str.split ('\n')]) 459 str = '\n'.join ([l[:80] for l in str.split ('\n')])
458 460
459 461
460 str = '<font size="-2"><pre>%s</pre></font>' % str 462 str = '<font size="-2"><pre>%s</pre></font>' % escape(str)
Julien Rioux 2011/11/07 15:53:49 ...use "cgi.escape (str)" here. The space before t
adam.spiers 2011/11/07 19:20:42 Done.
461 return str 463 return str
462 464
463 def calc_distance (self): 465 def calc_distance (self):
464 if self.contents[0] == self.contents[1]: 466 if self.contents[0] == self.contents[1]:
465 d = 0.0 467 d = 0.0
466 else: 468 else:
467 d = 1.0001 *options.threshold 469 d = 1.0001 *options.threshold
468 470
469 return d 471 return d
470 472
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 def create_text_result_page (self, dir1, dir2, dest_dir, threshold): 937 def create_text_result_page (self, dir1, dir2, dest_dir, threshold):
936 self.write_text_result_page (dest_dir + '/index.txt', threshold) 938 self.write_text_result_page (dest_dir + '/index.txt', threshold)
937 939
938 def create_html_result_page (self, dir1, dir2, dest_dir, threshold): 940 def create_html_result_page (self, dir1, dir2, dest_dir, threshold):
939 dir1 = dir1.replace ('//', '/') 941 dir1 = dir1.replace ('//', '/')
940 dir2 = dir2.replace ('//', '/') 942 dir2 = dir2.replace ('//', '/')
941 943
942 (changed, below, unchanged) = self.thresholded_results (threshold) 944 (changed, below, unchanged) = self.thresholded_results (threshold)
943 945
944 946
945 html = '' 947 table_rows = ''
946 old_prefix = os.path.split (dir1)[1] 948 old_prefix = os.path.split (dir1)[1]
947 for link in changed: 949 for link in changed:
948 html += link.html_record_string (dest_dir) 950 table_rows += link.html_record_string (dest_dir)
949 951
950 952
951 short_dir1 = shorten_string (dir1) 953 short_dir1 = shorten_string (dir1)
952 short_dir2 = shorten_string (dir2) 954 short_dir2 = shorten_string (dir2)
955
956 summary = ''
957 below_count = len (below)
958
959 if below_count:
960 summary += '<p>%d below threshold</p>' % below_count
961
962 summary += '<p>%d unchanged</p>' % len (unchanged)
963
953 html = '''<html> 964 html = '''<html>
965 <head>
966 <title>LilyPond regression test results</title>
967 <script language="javascript" type="text/javascript">
968 // <![CDATA[
969 var rows = document.getElementsByTagName("tr");
970 function showOnlyMatchingRows(substring) {
971 var rowcount = rows.length;
972 for (var i = 0; i < rowcount; i++) {
973 row = rows[i];
974 html = row.innerHTML;
975 row.style.display =
976 (html.indexOf(substring + '">') != -1) ? "" : "none";
977 }
978 }
979 // ]]>
980 </script>
981 </head>
982 <body>
983 <p>
984 click to filter rows by type:
985 <a href="#" onClick="showOnlyMatchingRows('.ly')">ly</a> /
986 <a href="#" onClick="showOnlyMatchingRows('.profile')">profiling</a> /
987 <a href="#" onClick="showOnlyMatchingRows('.signature')">signature</a> /
988 <a href="#" onClick="showOnlyMatchingRows('.midi')">midi</a> /
989 <a href="#" onClick="showOnlyMatchingRows('.log')">log</a> /
990 <a href="#" onClick="showOnlyMatchingRows('.gittxt')">gittxt</a> /
991 <a href="#" onClick="showOnlyMatchingRows('')">reset to all</a>
992 </p>
993
994 <hr />
995
996 %(summary)s
997
998 <hr />
999
954 <table rules="rows" border bordercolor="blue"> 1000 <table rules="rows" border bordercolor="blue">
955 <tr> 1001 <tr>
956 <th>distance</th> 1002 <th>distance</th>
957 <th>%(short_dir1)s</th> 1003 <th>%(short_dir1)s</th>
958 <th>%(short_dir2)s</th> 1004 <th>%(short_dir2)s</th>
959 </tr> 1005 </tr>
960 %(html)s 1006 %(table_rows)s
961 </table> 1007 </table>
1008 </body>
962 </html>''' % locals() 1009 </html>''' % locals()
963 1010
964 html += ('<p>')
965 below_count = len (below)
966
967 if below_count:
968 html += ('<p>%d below threshold</p>' % below_count)
969
970 html += ('<p>%d unchanged</p>' % len (unchanged))
971
972 dest_file = dest_dir + '/index.html' 1011 dest_file = dest_dir + '/index.html'
973 open_write_file (dest_file).write (html) 1012 open_write_file (dest_file).write (html)
974 1013
975 1014
976 for link in changed: 1015 for link in changed:
977 link.link_files_for_html (dest_dir) 1016 link.link_files_for_html (dest_dir)
978 1017
979 1018
980 def print_results (self, threshold): 1019 def print_results (self, threshold):
981 self.write_text_result_page ('', threshold) 1020 self.write_text_result_page ('', threshold)
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 type="string", 1294 type="string",
1256 help='where to put the test results [tree2/compare-tree1tree2] ') 1295 help='where to put the test results [tree2/compare-tree1tree2] ')
1257 1296
1258 global options 1297 global options
1259 (options, args) = p.parse_args () 1298 (options, args) = p.parse_args ()
1260 1299
1261 if options.run_test: 1300 if options.run_test:
1262 run_tests () 1301 run_tests ()
1263 sys.exit (0) 1302 sys.exit (0)
1264 1303
1265 if len (args) % 2: 1304 if len (args) % 2 == 1:
Graham Percival 2011/11/07 08:52:52 why is there a mod here? Surely we just want to c
dak 2011/11/07 09:15:05 Uh, yes? See line 1313: the argument list consist
1266 p.print_usage () 1305 p.print_usage ()
1267 sys.exit (2) 1306 sys.exit (2)
1268 1307
1269 out = options.output_dir 1308 out = options.output_dir
1270 if not out: 1309 if not out:
1271 out = args[0].replace ('/', '') 1310 out = args[0].replace ('/', '')
1272 out = os.path.join (args[1], 'compare-' + shorten_string (out)) 1311 out = os.path.join (args[1], 'compare-' + shorten_string (out))
1273 1312
1274 compare_tree_pairs (zip (args[0::2], args[1::2]), out, options.threshold) 1313 compare_tree_pairs (zip (args[0::2], args[1::2]), out, options.threshold)
1275 1314
1276 if __name__ == '__main__': 1315 if __name__ == '__main__':
1277 main () 1316 main ()
1278 1317
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b