system ('convert -depth 8 -crop %dx%d+0+0 %s %s/crop1.png' % (dims + (old, dir)))
system ('convert -depth 8 -crop %dx%d+0+0 %s %s/crop2.png' % (dims + (new, dir)))
- system ('compare -depth 8 -dissimilarity-threshold 1 %(dir)s/crop1.png %(dir)s/crop2.png %(dir)s/diff.png' % locals ())
+ system1 ('compare -depth 8 -dissimilarity-threshold 1 %(dir)s/crop1.png %(dir)s/crop2.png %(dir)s/diff.png' % locals ())
system ("convert -depth 8 %(dir)s/diff.png -blur 0x3 -negate -channel alpha,blue -type TrueColorMatte -fx 'intensity' %(dir)s/matte.png" % locals ())
base = os.path.splitext (base)[0]
base = hash_to_original_name.get (base, base)
base = os.path.splitext (base)[0]
- return base
+ return os.path.join (self.prefix (), base)
def prefix (self):
return os.path.dirname (os.path.commonprefix (self.file_names))
str = ''
if oldnew == 1:
str = '\n'.join ([d.replace ('\n','') for d in self.diff_lines])
- str = '<font size="-2"><pre>%s</pre></font>' % str
+ str = '<font size="-2"><pre>%s</pre></font>' % cgi.escape (str)
return str
class LogFileCompareLink (TextFileCompareLink):
str += '%-8s: %8d (%5.3f)\n' % (k, int (self.results[oldnew][k]),
self.get_ratio (k))
- return '<pre>%s</pre>' % str
+ return '<pre>%s</pre>' % cgi.escape (str)
def get_ratio (self, key):
(v1,v2) = (self.results[0].get (key, -1),
cmd = ('gs -sDEVICE=png16m -dGraphicsAlphaBits=4 -dTextAlphaBits=4 '
' %(data_option)s '
' -r101 '
+ ' -dAutoRotatePages=/None '
' -sOutputFile=%(outfile)s -dNOSAFER -dEPSCrop -q -dNOPAUSE '
' %(infile)s -c quit ') % locals ()
re.sub (r'\\sourcefilename "([^"]+)"',
note_original, open (sf).read ())
else:
- print 'no source for', val
+ print 'no source for', val.file_names[1]
def compare_trees (self, dir1, dir2):
self.compare_directories (dir1, dir2)
sys.exit(1)
for d in dirs:
+ # don't walk the share folders
+ if d.startswith("share"):
+ continue
+
d1 = os.path.join (dir1, d)
d2 = os.path.join (dir2, d)
self.compare_general_files (klasses[ext], f1, f2)
def compare_general_files (self, klass, f1, f2):
+ prefix = os.path.commonprefix ([f1, f2])
name = os.path.split (f1)[1]
+ name = os.path.join (prefix, name)
file_link = klass (f1, f2)
self.file_links[name] = file_link
def compare_signature_files (self, f1, f2):
+ prefix = os.path.commonprefix ([f1, f2])
name = os.path.split (f1)[1]
name = re.sub ('-[0-9]+.signature', '', name)
+ name = os.path.join (prefix, name)
file_link = None
try:
out.write ('%d below threshold\n' % len (below))
out.write ('%d unchanged\n' % len (unchanged))
- def create_text_result_page (self, dir1, dir2, dest_dir, threshold):
+ def create_text_result_page (self, dest_dir, threshold):
self.write_text_result_page (dest_dir + '/index.txt', threshold)
- def create_html_result_page (self, dir1, dir2, dest_dir, threshold):
- dir1 = dir1.replace ('//', '/')
- dir2 = dir2.replace ('//', '/')
-
+ def create_html_result_page (self, dest_dir, threshold):
(changed, below, unchanged) = self.thresholded_results (threshold)
header_row = '''
summary += '<p>%d unchanged</p>' % len (unchanged)
+ me = sys.argv[0]
+
html = '''<html>
<head>
<title>LilyPond regression test results</title>
+<meta name="author" content="This file was autogenerated by %(me)s">
<script language="javascript" type="text/javascript">
// <![CDATA[
var rows = document.getElementsByTagName("tr");
system ('rm -rf %s '% dest_dir)
data.write_changed (dest_dir, threshold)
- data.create_html_result_page (dir1, dir2, dest_dir, threshold)
- data.create_text_result_page (dir1, dir2, dest_dir, threshold)
+ data.create_html_result_page (dest_dir, threshold)
+ data.create_text_result_page (dest_dir, threshold)
################################################################
# TESTING
stat = os.system (x)
assert stat == 0
+def system1 (x):
+# Allow exit status 0 and 1
+ print 'invoking', x
+ stat = os.system (x)
+ assert (stat == 0) or (stat == 256) # This return value convention is sick.
+
def test_paired_files ():
print paired_files (os.environ["HOME"] + "/src/lilypond/scripts/",