[llvm] r187856 - [lit] Use dual-compatible print() syntax where possible.

Daniel Dunbar daniel at zuster.org
Tue Aug 6 20:18:36 PDT 2013


Author: ddunbar
Date: Tue Aug  6 22:18:36 2013
New Revision: 187856

URL: http://llvm.org/viewvc/llvm-project?rev=187856&view=rev
Log:
[lit] Use dual-compatible print() syntax where possible.

Modified:
    llvm/trunk/utils/lit/lit/Util.py
    llvm/trunk/utils/lit/lit/main.py

Modified: llvm/trunk/utils/lit/lit/Util.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/Util.py?rev=187856&r1=187855&r2=187856&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/Util.py (original)
+++ llvm/trunk/utils/lit/lit/Util.py Tue Aug  6 22:18:36 2013
@@ -116,27 +116,25 @@ def printHistogram(items, title = 'Items
 
     barW = 40
     hr = '-' * (barW + 34)
-    print '\nSlowest %s:' % title
-    print hr
+    print('\nSlowest %s:' % title)
+    print(hr)
     for name,value in items[-20:]:
-        print '%.2fs: %s' % (value, name)
-    print '\n%s Times:' % title
-    print hr
+        print('%.2fs: %s' % (value, name))
+    print('\n%s Times:' % title)
+    print(hr)
     pDigits = int(math.ceil(math.log(maxValue, 10)))
     pfDigits = max(0, 3-pDigits)
     if pfDigits:
         pDigits += pfDigits + 1
     cDigits = int(math.ceil(math.log(len(items), 10)))
-    print "[%s] :: [%s] :: [%s]" % ('Range'.center((pDigits+1)*2 + 3),
+    print("[%s] :: [%s] :: [%s]" % ('Range'.center((pDigits+1)*2 + 3),
                                     'Percentage'.center(barW),
-                                    'Count'.center(cDigits*2 + 1))
-    print hr
+                                    'Count'.center(cDigits*2 + 1)))
+    print(hr)
     for i,row in enumerate(histo):
         pct = float(len(row)) / len(items)
         w = int(barW * pct)
-        print "[%*.*fs,%*.*fs)" % (pDigits, pfDigits, i*barH,
-                                   pDigits, pfDigits, (i+1)*barH),
-        print ":: [%s%s] :: [%*d/%*d]" % ('*'*w, ' '*(barW-w),
-                                          cDigits, len(row),
-                                          cDigits, len(items))
+        print("[%*.*fs,%*.*fs) :: [%s%s] :: [%*d/%*d]" % (
+            pDigits, pfDigits, i*barH, pDigits, pfDigits, (i+1)*barH,
+            '*'*w, ' '*(barW-w), cDigits, len(row), cDigits, len(items)))
 

Modified: llvm/trunk/utils/lit/lit/main.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/main.py?rev=187856&r1=187855&r2=187856&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/main.py (original)
+++ llvm/trunk/utils/lit/lit/main.py Tue Aug  6 22:18:36 2013
@@ -59,14 +59,14 @@ class TestingProgressDisplay:
         if self.progressBar:
             self.progressBar.clear()
 
-        print '%s: %s (%d of %d)' % (test.result.name, test.getFullName(),
-                                     self.completed, self.numTests)
+        print('%s: %s (%d of %d)' % (test.result.name, test.getFullName(),
+                                     self.completed, self.numTests))
 
         if test.result.isFailure and self.opts.showOutput:
-            print "%s TEST '%s' FAILED %s" % ('*'*20, test.getFullName(),
-                                              '*'*20)
-            print test.output
-            print "*" * 20
+            print("%s TEST '%s' FAILED %s" % ('*'*20, test.getFullName(),
+                                              '*'*20))
+            print(test.output)
+            print("*" * 20)
 
         sys.stdout.flush()
 
@@ -125,7 +125,7 @@ class Tester(threading.Thread):
         except KeyboardInterrupt:
             # This is a sad hack. Unfortunately subprocess goes
             # bonkers with ctrl-c and we start forking merrily.
-            print '\nCtrl-C detected, goodbye.'
+            print('\nCtrl-C detected, goodbye.')
             os.kill(0,9)
         except:
             if self.litConfig.debug:
@@ -299,19 +299,19 @@ def main(builtinParameters = {}):
 
         # Show the suites, if requested.
         if opts.showSuites:
-            print '-- Test Suites --'
+            print('-- Test Suites --')
             for ts,ts_tests in suitesAndTests:
-                print '  %s - %d tests' %(ts.name, len(ts_tests))
-                print '    Source Root: %s' % ts.source_root
-                print '    Exec Root  : %s' % ts.exec_root
+                print('  %s - %d tests' %(ts.name, len(ts_tests)))
+                print('    Source Root: %s' % ts.source_root)
+                print('    Exec Root  : %s' % ts.exec_root)
 
         # Show the tests, if requested.
         if opts.showTests:
-            print '-- Available Tests --'
+            print('-- Available Tests --')
             for ts,ts_tests in suitesAndTests:
                 ts_tests.sort(key = lambda test: test.path_in_suite)
                 for test in ts_tests:
-                    print '  %s' % (test.getFullName(),)
+                    print('  %s' % (test.getFullName(),))
         
     # Select and order the tests.
     numTotalTests = len(tests)
@@ -357,10 +357,10 @@ def main(builtinParameters = {}):
                 tc = ProgressBar.TerminalController()
                 progressBar = ProgressBar.ProgressBar(tc, header)
             except ValueError:
-                print header
+                print(header)
                 progressBar = ProgressBar.SimpleProgressBar('Testing: ')
         else:
-            print header
+            print(header)
 
     startTime = time.time()
     display = TestingProgressDisplay(opts, len(tests), progressBar)
@@ -380,7 +380,7 @@ def main(builtinParameters = {}):
     display.finish()
 
     if not opts.quiet:
-        print 'Testing Time: %.2fs'%(time.time() - startTime)
+        print('Testing Time: %.2fs'%(time.time() - startTime))
 
     # Update results for any tests which weren't run.
     for t in tests:
@@ -403,10 +403,10 @@ def main(builtinParameters = {}):
         elts = byCode.get(code)
         if not elts:
             continue
-        print '*'*20
-        print '%s (%d):' % (title, len(elts))
+        print('*'*20)
+        print('%s (%d):' % (title, len(elts)))
         for t in elts:
-            print '    %s' % t.getFullName()
+            print('    %s' % t.getFullName())
         print
 
     if opts.timeTests:
@@ -431,7 +431,7 @@ def main(builtinParameters = {}):
             continue
         N = len(byCode.get(code,[]))
         if N:
-            print '  %s: %d' % (name,N)
+            print('  %s: %d' % (name,N))
 
     # If we encountered any additional errors, exit abnormally.
     if litConfig.numErrors:





More information about the llvm-commits mailing list