lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issue 5576: make output-distance less verbose by default (issue 58122004


From: nine . fierce . ballads
Subject: Issue 5576: make output-distance less verbose by default (issue 581220043 by address@hidden)
Date: Mon, 28 Oct 2019 09:15:54 -0700

Reviewers: ,


https://codereview.appspot.com/581220043/diff/551140043/scripts/build/output-distance.py
File scripts/build/output-distance.py (right):

https://codereview.appspot.com/581220043/diff/551140043/scripts/build/output-distance.py#newcode912
scripts/build/output-distance.py:912: log_terse ('%6d %s' %
(len(paired), ext))
This is the line that differs from the first attempt.

Description:
https://sourceforge.net/p/testlilyissues/issues/5576/

This is a resubmission of 306fc6b509a9e71e16d54e11d11d70968aa4c3ef
with an expression removed that was found not to be supported by an
older version of Python than 2.7.

The previous code review is https://codereview.appspot.com/563120043/

Please review this at https://codereview.appspot.com/581220043/

Affected files (+46, -21 lines):
  M GNUmakefile.in
  M scripts/build/output-distance.py


Index: GNUmakefile.in
diff --git a/GNUmakefile.in b/GNUmakefile.in
index 93a4a3fec2f889d9676d44036258cdc2abf38406..77b24aecf758bc887fd63416dc2b5952f4c20111 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -369,7 +369,8 @@ local-check-pre:
 local-check: local-check-pre
        rm -rf $(RESULT_DIR)
        mkdir -p $(RESULT_DIR)
- $(buildscript-dir)/output-distance --local-datadir --create-images --output-dir $(RESULT_DIR) \
+       $(buildscript-dir)/output-distance $(if $(VERBOSE),-v) \
+               --local-datadir --create-images --output-dir $(RESULT_DIR) \
                input/regression/out-test-baseline input/regression/out-test \
                input/regression/midi/out-test-baseline 
input/regression/midi/out-test
@find input ly -name '*.ly' -print |grep -v 'out.*/' | xargs grep '\\version' -L | grep -v "standard input" |sed 's/^/**** Missing version: /g'
Index: scripts/build/output-distance.py
diff --git a/scripts/build/output-distance.py b/scripts/build/output-distance.py index 6e2571c88fe2d5992e50b534097733a6bb8d33fb..e68a4c0ece990e14e5f1326b57cf6bb51c173c37 100755
--- a/scripts/build/output-distance.py
+++ b/scripts/build/output-distance.py
@@ -21,6 +21,14 @@ OUTPUT_EXPRESSION_PENALTY = 1
 ORPHAN_GROB_PENALTY = 1
 options = None

+def log_terse (s):
+    if not options.verbose:
+        print s
+
+def log_verbose (s):
+    if options.verbose:
+        print s
+
 ################################################################
 # system interface.
 temp_dir = None
@@ -28,9 +36,9 @@ class TempDirectory:
     def __init__ (self):
         import tempfile
         self.dir = tempfile.mkdtemp ()
-        print 'dir is', self.dir
+        log_verbose ('dir is %s' % self.dir)
     def __del__ (self):
-        print 'rm -rf %s' % self.dir
+        log_verbose ('rm -rf %s' % self.dir)
         os.system ('rm -rf %s' % self.dir)
     def __call__ (self):
         return self.dir
@@ -43,11 +51,11 @@ def get_temp_dir  ():
     return temp_dir ()

 def read_pipe (c):
-    print 'pipe' , c
+    log_verbose ('pipe %s' % c)
     return os.popen (c).read ()

 def system (c):
-    print 'system' , c
+    log_verbose ('system %s' % c)
     s = os.system (c)
     if s :
         raise Exception ("failed")
@@ -321,7 +329,7 @@ def scheme_float (s) :
     return float(s.split('.')[0])

 def read_signature_file (name):
-    print 'reading', name
+    log_verbose ('reading %s' % name)

     entries = open (name).read ().split ('\n')
     def string_to_tup (s):
@@ -451,7 +459,7 @@ class FileCompareLink (FileLink):
             return 100.0;

     def get_content (self, f):
-        print 'reading', f
+        log_verbose ('reading %s' % f)
         s = open (f).read ()
         return s

@@ -647,7 +655,7 @@ class SignatureFileLink (FileLink):
             abs_dir = os.path.abspath (dir)
             cur_dir = os.getcwd ()

-            print 'entering directory', abs_dir
+            log_verbose ('entering directory %s' % abs_dir)
             os.chdir (dir)

             for f in glob.glob (base):
@@ -674,9 +682,10 @@ class SignatureFileLink (FileLink):
                        ' -c quit') % locals ()

                 files_created[oldnew].append (outfile)
+                log_terse ('writing %s' % outfile)
                 system (cmd)

-            print 'leaving directory', abs_dir
+            log_verbose ('leaving directory %s' % abs_dir)
             os.chdir (cur_dir)

         return files_created
@@ -887,6 +896,9 @@ class ComparisonData:
                 self.compare_trees (d1, d2)

     def compare_directories (self, dir1, dir2):
+        log_terse ('comparing %s' % dir1)
+        log_terse ('       to %s' % dir2)
+
         for ext in ['signature',
                     'midi',
                     'log',
@@ -897,6 +909,8 @@ class ComparisonData:
             self.missing += [(dir1, m) for m in m1]
             self.added += [(dir2, m) for m in m2]

+            log_terse ('%6d %s' % (len(paired), ext))
+
             # we sort the file names for easier debugging
             for p in sorted (paired):
                 if (options.max_count
@@ -971,21 +985,26 @@ class ComparisonData:

     def write_text_result_page (self, filename, threshold):
         out = None
+        verbose = True
         if filename == '':
             out = sys.stdout
+            verbose = options.verbose
         else:
-            print 'writing "%s"' % filename
+            print 'writing %s' % filename
             out = open_write_file (filename)

         (changed, below, unchanged) = self.thresholded_results (threshold)

+        if verbose:
+            for link in changed:
+                out.write (link.text_record_string ())
+            out.write ('\n\n')
+        else:
+            out.write ('output-distance summary:\n')
+            out.write ('%6d changed\n' % len (changed))

-        for link in changed:
-            out.write (link.text_record_string ())
-
-        out.write ('\n\n')
-        out.write ('%d below threshold\n' % len (below))
-        out.write ('%d unchanged\n' % len (unchanged))
+        out.write ('%6d below threshold\n' % len (below))
+        out.write ('%6d unchanged\n' % len (unchanged))

     def create_text_result_page (self, dest_dir, threshold):
         self.write_text_result_page (dest_dir + '/index.txt', threshold)
@@ -1097,13 +1116,13 @@ def compare_tree_pairs (tree_pairs, dest_dir, threshold):

 def mkdir (x):
     if not os.path.isdir (x):
-        print 'mkdir', x
+        log_verbose ('mkdir %s' % x)
         os.makedirs (x)

 def link_file (x, y):
     mkdir (os.path.split (y)[0])
     try:
-        print x, '->', y
+        log_verbose ('%s -> %s' % (x, y))
         os.link (x, y)
     except OSError, z:
         print 'OSError', x, y, z
@@ -1116,14 +1135,13 @@ def open_write_file (x):


 def system (x):
-
-    print 'invoking', x
+    log_verbose ('invoking %s' % x)
     stat = os.system (x)
     assert stat == 0

 def system1 (x):
 # Allow exit status 0 and 1
-    print 'invoking', x
+    log_verbose ('invoking %s' % x)
     stat = os.system (x)
assert (stat == 0) or (stat == 256) # This return value convention is sick.

@@ -1358,6 +1376,12 @@ def main ():
                   type="string",
help='where to put the test results [tree2/compare-tree1tree2]')

+    p.add_option ('-v', '--verbose',
+                  dest="verbose",
+                  default=False,
+                  action="store_true",
+                  help='log progress verbosely')
+
     global options
     (options, args) = p.parse_args ()






reply via email to

[Prev in Thread] Current Thread [Next in Thread]