LEFT | RIGHT |
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 import cgi | 8 import cgi |
9 | 9 |
10 ## so we can call directly as scripts/build/output-distance.py | 10 ## so we can call directly as scripts/build/output-distance.py |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 sf = val.source_file () | 825 sf = val.source_file () |
826 if sf: | 826 if sf: |
827 re.sub (r'\\sourcefilename "([^"]+)"', | 827 re.sub (r'\\sourcefilename "([^"]+)"', |
828 note_original, open (sf).read ()) | 828 note_original, open (sf).read ()) |
829 else: | 829 else: |
830 print 'no source for', val.file_names[1] | 830 print 'no source for', val.file_names[1] |
831 | 831 |
832 def compare_trees (self, dir1, dir2): | 832 def compare_trees (self, dir1, dir2): |
833 self.compare_directories (dir1, dir2) | 833 self.compare_directories (dir1, dir2) |
834 | 834 |
835 try: | 835 (root, dirs, files) = os.walk (dir1).next () |
836 (root, dirs, files) = os.walk (dir1).next () | |
837 except StopIteration: | |
838 if dir1.endswith("-baseline"): | |
839 sys.stderr.write("Failed to walk through %s. This can be caused
by forgetting to run make test-baseline.\n" % dir1) | |
840 else: | |
841 sys.stderr.write("Failed to walk through %s; please check it exi
sts.\n" % dir1) | |
842 sys.exit(1) | |
843 | 836 |
844 for d in dirs: | 837 for d in dirs: |
845 # don't walk the share folders | 838 # don't walk the share folders |
846 if d.startswith("share"): | 839 if d.startswith("share"): |
847 continue | 840 continue |
848 | 841 |
849 d1 = os.path.join (dir1, d) | 842 d1 = os.path.join (dir1, d) |
850 d2 = os.path.join (dir2, d) | 843 d2 = os.path.join (dir2, d) |
851 | 844 |
852 if os.path.islink (d1) or os.path.islink (d2): | 845 if os.path.islink (d1) or os.path.islink (d2): |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 for link in changed: | 1037 for link in changed: |
1045 link.link_files_for_html (dest_dir) | 1038 link.link_files_for_html (dest_dir) |
1046 | 1039 |
1047 | 1040 |
1048 def print_results (self, threshold): | 1041 def print_results (self, threshold): |
1049 self.write_text_result_page ('', threshold) | 1042 self.write_text_result_page ('', threshold) |
1050 | 1043 |
1051 def compare_tree_pairs (tree_pairs, dest_dir, threshold): | 1044 def compare_tree_pairs (tree_pairs, dest_dir, threshold): |
1052 data = ComparisonData () | 1045 data = ComparisonData () |
1053 for dir1, dir2 in tree_pairs: | 1046 for dir1, dir2 in tree_pairs: |
1054 data.compare_trees (dir1, dir2) | 1047 try: |
| 1048 data.compare_trees (dir1, dir2) |
| 1049 except StopIteration: |
| 1050 sys.stderr.write("Warning: Failed to walk through %s.\n" % dir1) |
| 1051 if dir1.endswith("-baseline"): |
| 1052 sys.stderr.write("Warning: This can be caused by forgetting to r
un make test-baseline.\n") |
| 1053 else: |
| 1054 sys.stderr.write("Warning: Please check that it exists.\n") |
| 1055 if dir1 == tree_pairs[0]: |
| 1056 raise Exception("Failed to walk through even the first dir %s."
% dir1) |
1055 data.read_sources () | 1057 data.read_sources () |
1056 | 1058 |
1057 data.print_results (threshold) | 1059 data.print_results (threshold) |
1058 | 1060 |
1059 if os.path.isdir (dest_dir): | 1061 if os.path.isdir (dest_dir): |
1060 system ('rm -rf %s '% dest_dir) | 1062 system ('rm -rf %s '% dest_dir) |
1061 | 1063 |
1062 data.write_changed (dest_dir, threshold) | 1064 data.write_changed (dest_dir, threshold) |
1063 data.create_html_result_page (dest_dir, threshold) | 1065 data.create_html_result_page (dest_dir, threshold) |
1064 data.create_text_result_page (dest_dir, threshold) | 1066 data.create_text_result_page (dest_dir, threshold) |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 out = options.output_dir | 1339 out = options.output_dir |
1338 if not out: | 1340 if not out: |
1339 out = args[0].replace ('/', '') | 1341 out = args[0].replace ('/', '') |
1340 out = os.path.join (args[1], 'compare-' + shorten_string (out)) | 1342 out = os.path.join (args[1], 'compare-' + shorten_string (out)) |
1341 | 1343 |
1342 compare_tree_pairs (zip (args[0::2], args[1::2]), out, options.threshold) | 1344 compare_tree_pairs (zip (args[0::2], args[1::2]), out, options.threshold) |
1343 | 1345 |
1344 if __name__ == '__main__': | 1346 if __name__ == '__main__': |
1345 main () | 1347 main () |
1346 | 1348 |
LEFT | RIGHT |