[llvm] r187857 - [lit] Use .write() methods instead of print statement.
Daniel Dunbar
daniel at zuster.org
Tue Aug 6 20:19:45 PDT 2013
Author: ddunbar
Date: Tue Aug 6 22:19:45 2013
New Revision: 187857
URL: http://llvm.org/viewvc/llvm-project?rev=187857&view=rev
Log:
[lit] Use .write() methods instead of print statement.
Modified:
llvm/trunk/utils/lit/lit/LitConfig.py
llvm/trunk/utils/lit/lit/ProgressBar.py
llvm/trunk/utils/lit/lit/ShCommands.py
llvm/trunk/utils/lit/lit/TestRunner.py
llvm/trunk/utils/lit/lit/discovery.py
llvm/trunk/utils/lit/lit/main.py
Modified: llvm/trunk/utils/lit/lit/LitConfig.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/LitConfig.py?rev=187857&r1=187856&r2=187857&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/LitConfig.py (original)
+++ llvm/trunk/utils/lit/lit/LitConfig.py Tue Aug 6 22:19:45 2013
@@ -112,8 +112,8 @@ class LitConfig:
file,line,_,_,_ = inspect.getframeinfo(f)
location = '%s:%d' % (os.path.basename(file), line)
- print >>sys.stderr, '%s: %s: %s: %s' % (self.progname, location,
- kind, message)
+ sys.stderr.write('%s: %s: %s: %s\n' % (self.progname, location,
+ kind, message))
def note(self, message):
self._write_message('note', message)
Modified: llvm/trunk/utils/lit/lit/ProgressBar.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/ProgressBar.py?rev=187857&r1=187856&r2=187857&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/ProgressBar.py (original)
+++ llvm/trunk/utils/lit/lit/ProgressBar.py Tue Aug 6 22:19:45 2013
@@ -16,13 +16,13 @@ class TerminalController:
output to the terminal:
>>> term = TerminalController()
- >>> print 'This is '+term.GREEN+'green'+term.NORMAL
+ >>> print('This is '+term.GREEN+'green'+term.NORMAL)
Alternatively, the `render()` method can used, which replaces
'${action}' with the string required to perform 'action':
>>> term = TerminalController()
- >>> print term.render('This is ${GREEN}green${NORMAL}')
+ >>> print(term.render('This is ${GREEN}green${NORMAL}'))
If the terminal doesn't support a given action, then the value of
the corresponding instance variable will be set to ''. As a
@@ -34,7 +34,7 @@ class TerminalController:
>>> term = TerminalController()
>>> if term.CLEAR_SCREEN:
- ... print 'This terminal supports clearning the screen.'
+ ... print('This terminal supports clearning the screen.')
Finally, if the width and height of the terminal are known, then
they will be stored in the `COLS` and `LINES` attributes.
Modified: llvm/trunk/utils/lit/lit/ShCommands.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/ShCommands.py?rev=187857&r1=187856&r2=187857&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/ShCommands.py (original)
+++ llvm/trunk/utils/lit/lit/ShCommands.py Tue Aug 6 22:19:45 2013
@@ -21,7 +21,7 @@ class Command:
quoted = '"%s"' % arg
else:
raise NotImplementedError('Unable to quote %r' % arg)
- print >>file, quoted,
+ file.write(quoted)
# For debugging / validation.
import ShUtil
@@ -31,9 +31,9 @@ class Command:
for r in self.redirects:
if len(r[0]) == 1:
- print >>file, "%s '%s'" % (r[0][0], r[1]),
+ file.write("%s '%s'" % (r[0][0], r[1]))
else:
- print >>file, "%s%s '%s'" % (r[0][1], r[0][0], r[1]),
+ file.write("%s%s '%s'" % (r[0][1], r[0][0], r[1]))
class Pipeline:
def __init__(self, commands, negate=False, pipe_err=False):
@@ -56,11 +56,11 @@ class Pipeline:
if pipefail != self.pipe_err:
raise ValueError('Inconsistent "pipefail" attribute!')
if self.negate:
- print >>file, '!',
+ file.write('! ')
for cmd in self.commands:
cmd.toShell(file)
if cmd is not self.commands[-1]:
- print >>file, '|\n ',
+ file.write('|\n ')
class Seq:
def __init__(self, lhs, op, rhs):
@@ -81,5 +81,5 @@ class Seq:
def toShell(self, file, pipefail=False):
self.lhs.toShell(file, pipefail)
- print >>file, ' %s\n' % self.op
+ file.write(' %s\n' % self.op)
self.rhs.toShell(file, pipefail)
Modified: llvm/trunk/utils/lit/lit/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestRunner.py?rev=187857&r1=187856&r2=187857&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/TestRunner.py (original)
+++ llvm/trunk/utils/lit/lit/TestRunner.py Tue Aug 6 22:19:45 2013
@@ -437,22 +437,21 @@ def parseIntegratedTestScript(test, norm
def formatTestOutput(status, out, err, exitCode, script):
output = StringIO.StringIO()
- print >>output, "Script:"
- print >>output, "--"
- print >>output, '\n'.join(script)
- print >>output, "--"
- print >>output, "Exit Code: %r" % exitCode,
- print >>output
+ output.write("Script:\n")
+ output.write("--\n")
+ output.write('\n'.join(script))
+ output.write("\n--\n")
+ output.write("Exit Code: %r\n\n" % exitCode)
if out:
- print >>output, "Command Output (stdout):"
- print >>output, "--"
+ output.write("Command Output (stdout):\n")
+ output.write("--\n")
output.write(out)
- print >>output, "--"
+ output.write("--\n")
if err:
- print >>output, "Command Output (stderr):"
- print >>output, "--"
+ output.write("Command Output (stderr):\n")
+ output.write("--\n")
output.write(err)
- print >>output, "--"
+ output.write("--\n")
return (status, output.getvalue())
def executeShTest(test, litConfig, useExternalSh,
Modified: llvm/trunk/utils/lit/lit/discovery.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/discovery.py?rev=187857&r1=187856&r2=187857&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/discovery.py (original)
+++ llvm/trunk/utils/lit/lit/discovery.py Tue Aug 6 22:19:45 2013
@@ -215,7 +215,7 @@ def find_tests_for_inputs(lit_config, in
# If there were any errors during test discovery, exit now.
if lit_config.numErrors:
- print >>sys.stderr, '%d errors, exiting.' % lit_config.numErrors
+ sys.stderr.write('%d errors, exiting.\n' % lit_config.numErrors)
sys.exit(2)
return tests
Modified: llvm/trunk/utils/lit/lit/main.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/main.py?rev=187857&r1=187856&r2=187857&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/main.py (original)
+++ llvm/trunk/utils/lit/lit/main.py Tue Aug 6 22:19:45 2013
@@ -407,7 +407,7 @@ def main(builtinParameters = {}):
print('%s (%d):' % (title, len(elts)))
for t in elts:
print(' %s' % t.getFullName())
- print
+ sys.stdout.write('\n')
if opts.timeTests:
# Collate, in case we repeated tests.
@@ -435,12 +435,12 @@ def main(builtinParameters = {}):
# If we encountered any additional errors, exit abnormally.
if litConfig.numErrors:
- print >>sys.stderr, '\n%d error(s), exiting.' % litConfig.numErrors
+ sys.stderr.write('\n%d error(s), exiting.\n' % litConfig.numErrors)
sys.exit(2)
# Warn about warnings.
if litConfig.numWarnings:
- print >>sys.stderr, '\n%d warning(s) in tests.' % litConfig.numWarnings
+ sys.stderr.write('\n%d warning(s) in tests.\n' % litConfig.numWarnings)
if hasFailures:
sys.exit(1)
More information about the llvm-commits
mailing list