]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 1529: hashed snippet filename changes should not count as log differences
authorReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 15 Aug 2011 17:37:29 +0000 (19:37 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 1 Sep 2011 13:12:51 +0000 (15:12 +0200)
If the contents of a regtest change, the regtest gets a new hash and
thus a new filename. Unfortunately, this will be detected by
output-distance as a change and will show up in the regtest analysis.
To work around this, I'm simply extracting the old and the new filename
before we compare the log files and if they differ, I replace the old
filename with the new filename in the old log file. Thus, it will
appear as if the new filename was also used in the baseline and it
will not be flagged as a difference.

scripts/build/output-distance.py

index 59499d16aca879705d59f6b2acad422a821919ff..b90bda55488480543c4837d4296788b56fcac30b 100644 (file)
@@ -3,6 +3,7 @@ import sys
 import optparse
 import os
 import math
+import re
 
 ## so we can call directly as scripts/build/output-distance.py
 me_path = os.path.abspath (os.path.split (sys.argv[0])[0])
@@ -468,11 +469,22 @@ class GitFileCompareLink (FileCompareLink):
         return d
 
 
+snippet_fn_re = re.compile (r"`\./([0-9a-f]{2}/lily-[0-9a-f]{8}).eps'");
 class TextFileCompareLink (FileCompareLink):
     def calc_distance (self):
         import difflib
-        diff = difflib.unified_diff (self.contents[0].strip().split ('\n'),
-                                     self.contents[1].strip().split ('\n'),
+        # Extract the old and the new hashed snippet names from the log file
+        # and replace the old by the new, so file name changes don't show
+        # up as log differences...
+        cont0 = self.contents[0].strip();
+        cont1 = self.contents[1].strip();
+        m0 = re.search (snippet_fn_re, cont0);
+        m1 = re.search (snippet_fn_re, cont1);
+        if (m0 and m1 and (m0.group(1) != m1.group(1))):
+            cont0 = cont0.replace (m0.group(1), m1.group(1));
+
+        diff = difflib.unified_diff (cont0.split ('\n'),
+                                     cont1.split ('\n'),
                                      fromfiledate = self.file_names[0],
                                      tofiledate = self.file_names[1]
                                      )
@@ -754,7 +766,6 @@ class SignatureFileLink (FileLink):
 # Files/directories
 
 import glob
-import re
 
 def compare_signature_files (f1, f2):
     s1 = read_signature_file (f1)