OLD | NEW |
1 #!@PYTHON@ | 1 #!@PYTHON@ |
2 | 2 |
3 import codecs | 3 import codecs |
4 import difflib | 4 import difflib |
5 import errno | 5 import errno |
6 import functools | 6 import functools |
7 import glob | 7 import glob |
8 import html | 8 import html |
9 import math | 9 import math |
10 import optparse | 10 import optparse |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 | 824 |
825 e = '<tr>%s</tr>' % e | 825 e = '<tr>%s</tr>' % e |
826 html += e | 826 html += e |
827 | 827 |
828 original = self.name () | 828 original = self.name () |
829 html = '''<!DOCTYPE html> | 829 html = '''<!DOCTYPE html> |
830 <html lang="en"> | 830 <html lang="en"> |
831 <head> | 831 <head> |
832 <title>comparison details for %(original)s</title> | 832 <title>comparison details for %(original)s</title> |
833 <link rel="stylesheet" type="text/css" href="%(style_href)s"/> | 833 <link rel="stylesheet" type="text/css" href="%(style_href)s"/> |
834 <meta charset="UTF-8"> | 834 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
835 </head> | 835 </head> |
836 <body> | 836 <body> |
837 <table> | 837 <table id="comparison_details" class="ruled_rows"> |
838 <tr> | 838 <tr> |
839 <th>system</th> | 839 <th>system</th> |
840 <th>orphan</th> | 840 <th>orphan</th> |
841 <th>geo</th> | 841 <th>geo</th> |
842 </tr> | 842 </tr> |
843 | 843 |
844 %(html)s | 844 %(html)s |
845 </table> | 845 </table> |
846 | 846 |
847 </body> | 847 </body> |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 --link-color: #59a0e0; | 1176 --link-color: #59a0e0; |
1177 } | 1177 } |
1178 } | 1178 } |
1179 ''') | 1179 ''') |
1180 | 1180 |
1181 html = '''<!DOCTYPE html> | 1181 html = '''<!DOCTYPE html> |
1182 <html lang="en"> | 1182 <html lang="en"> |
1183 <head> | 1183 <head> |
1184 <title>LilyPond regression test results</title> | 1184 <title>LilyPond regression test results</title> |
1185 <link rel="stylesheet" type="text/css" href="style.css"/> | 1185 <link rel="stylesheet" type="text/css" href="style.css"/> |
1186 <meta charset="UTF-8"> | 1186 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
1187 <meta name="author" content="This file was autogenerated by %(me)s"/> | 1187 <meta name="author" content="This file was autogenerated by %(me)s"/> |
1188 <script> | 1188 <script> |
1189 // <![CDATA[ | 1189 // <![CDATA[ |
1190 function showOnlyMatchingRows(substring) { | 1190 function showOnlyMatchingRows(substring) { |
1191 var table = document.getElementById("test_cases"); | 1191 var table = document.getElementById("test_cases"); |
1192 for (row of table.getElementsByTagName("tr")) { | 1192 for (row of table.getElementsByTagName("tr")) { |
1193 html = row.innerHTML; | 1193 html = row.innerHTML; |
1194 row.style.display = | 1194 row.style.display = |
1195 ((html.indexOf('>distance<') != -1) || | 1195 ((html.indexOf('>distance<') != -1) || |
1196 (html.indexOf(substring + '">') != -1)) ? "" : "none"; | 1196 (html.indexOf(substring + '">') != -1)) ? "" : "none"; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 "dir2/20grob.png", | 1363 "dir2/20grob.png", |
1364 "dir1/20grob.png", | 1364 "dir1/20grob.png", |
1365 "style.css", | 1365 "style.css", |
1366 ]: | 1366 ]: |
1367 fn = os.path.join("compare-dir1dir2", f) | 1367 fn = os.path.join("compare-dir1dir2", f) |
1368 assert os.path.exists(fn), fn | 1368 assert os.path.exists(fn), fn |
1369 html = open("compare-dir1dir2/index.html").read() | 1369 html = open("compare-dir1dir2/index.html").read() |
1370 assert "removed.log" in html | 1370 assert "removed.log" in html |
1371 assert "added.log" in html | 1371 assert "added.log" in html |
1372 | 1372 |
| 1373 |
1373 def test_basic_compare (): | 1374 def test_basic_compare (): |
1374 ly_template = r""" | 1375 ly_template = r""" |
1375 | 1376 |
1376 \version "2.10.0" | 1377 \version "2.10.0" |
1377 #(define default-toplevel-book-handler | 1378 #(define default-toplevel-book-handler |
1378 print-book-with-defaults-as-systems ) | 1379 print-book-with-defaults-as-systems ) |
1379 | 1380 |
1380 #(ly:set-option (quote no-point-and-click)) | 1381 #(ly:set-option (quote no-point-and-click)) |
1381 | 1382 |
1382 \sourcefilename "my-source.ly" | 1383 \sourcefilename "my-source.ly" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 print('%-20s' % k, v) | 1477 print('%-20s' % k, v) |
1477 | 1478 |
1478 assert links["20grob-20"].orphan_count() > 0 | 1479 assert links["20grob-20"].orphan_count() > 0 |
1479 assert combinations['20-20'] == (0.0, 0.0) | 1480 assert combinations['20-20'] == (0.0, 0.0) |
1480 assert combinations['20-19'][1] < 10.0 | 1481 assert combinations['20-19'][1] < 10.0 |
1481 assert combinations['20-19'][1] > 0.0 | 1482 assert combinations['20-19'][1] > 0.0 |
1482 assert combinations['20grob-20'][0] > 0 | 1483 assert combinations['20grob-20'][0] > 0 |
1483 | 1484 |
1484 | 1485 |
1485 def run_tests (): | 1486 def run_tests (): |
1486 dir = 'test-output-distance' | 1487 testdir = os.path.join(options.output_dir, 'test-output-distance') |
| 1488 print('test results in ', testdir) |
1487 | 1489 |
1488 do_clean = not os.path.exists (dir) | 1490 system ('rm -rf ' + testdir) |
1489 | 1491 system ('mkdir ' + testdir) |
1490 print('test results in ', dir) | 1492 os.chdir (testdir) |
1491 | |
1492 system ('rm -rf ' + dir) | |
1493 system ('mkdir ' + dir) | |
1494 | |
1495 os.chdir (dir) | |
1496 | 1493 |
1497 test_basic_compare () | 1494 test_basic_compare () |
1498 test_compare_tree_pairs () | 1495 test_compare_tree_pairs () |
| 1496 system ('rm -rf ' + testdir) |
1499 | 1497 |
1500 ################################################################ | 1498 ################################################################ |
1501 # | 1499 # |
1502 | 1500 |
1503 def main (): | 1501 def main (): |
1504 p = optparse.OptionParser ("output-distance - compare LilyPond formatting ru
ns") | 1502 p = optparse.OptionParser ("output-distance - compare LilyPond formatting ru
ns") |
1505 p.usage = 'output-distance.py [options] tree1 tree2 [tree3 tree4]...' | 1503 p.usage = 'output-distance.py [options] tree1 tree2 [tree3 tree4]...' |
1506 | 1504 |
1507 p.add_option ('', '--test-self', | 1505 p.add_option ('', '--test-self', |
1508 dest="run_test", | 1506 dest="run_test", |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 | 1554 |
1557 out = options.output_dir | 1555 out = options.output_dir |
1558 if not out: | 1556 if not out: |
1559 out = args[0].replace ('/', '') | 1557 out = args[0].replace ('/', '') |
1560 out = os.path.join (args[1], 'compare-' + shorten_string (out)) | 1558 out = os.path.join (args[1], 'compare-' + shorten_string (out)) |
1561 | 1559 |
1562 compare_tree_pairs (list(zip(args[0::2], args[1::2])), out, options.threshol
d) | 1560 compare_tree_pairs (list(zip(args[0::2], args[1::2])), out, options.threshol
d) |
1563 | 1561 |
1564 if __name__ == '__main__': | 1562 if __name__ == '__main__': |
1565 main () | 1563 main () |
OLD | NEW |