summaryrefslogtreecommitdiff
path: root/utils/UpdateTestChecks
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2018-02-02 16:41:07 +0000
committerFangrui Song <maskray@google.com>2018-02-02 16:41:07 +0000
commitb02fa517300d9c532085d8863c79c11cbbd0b9dd (patch)
tree5cb5151418c6d2b1c363d0c8e3fc65dfc4db65d5 /utils/UpdateTestChecks
parenta2386c3b26158ebe965b2d7aea1581f20ce9b84a (diff)
Make utils/UpdateTestChecks/common.py Python 2/3 compatible and fix print statements.
Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D42674 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@324104 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/UpdateTestChecks')
-rw-r--r--utils/UpdateTestChecks/common.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/utils/UpdateTestChecks/common.py b/utils/UpdateTestChecks/common.py
index f8f75c8b712..b95dd69c238 100644
--- a/utils/UpdateTestChecks/common.py
+++ b/utils/UpdateTestChecks/common.py
@@ -1,5 +1,7 @@
+from __future__ import print_function
import re
import subprocess
+import sys
RUN_LINE_RE = re.compile('^\s*;\s*RUN:\s*(.*)$')
CHECK_PREFIX_RE = re.compile('--?check-prefix(?:es)?=(\S+)')
@@ -35,9 +37,10 @@ def invoke_tool(exe, cmd_args, ir):
with open(ir) as ir_file:
stdout = subprocess.check_output(exe + ' ' + cmd_args,
shell=True, stdin=ir_file)
+ if sys.version_info[0] > 2:
+ stdout = stdout.decode()
# Fix line endings to unix CR style.
- stdout = stdout.replace('\r\n', '\n')
- return stdout
+ return stdout.replace('\r\n', '\n')
# Build up a dictionary of all the function bodies.
def build_function_body_dictionary(function_re, scrubber, scrubber_args, raw_tool_output, prefixes, func_dict, verbose):
@@ -50,14 +53,14 @@ def build_function_body_dictionary(function_re, scrubber, scrubber_args, raw_too
# We only use the last line of the function body for stress tests.
scrubbed_body = '\n'.join(scrubbed_body.splitlines()[-1:])
if verbose:
- print >>sys.stderr, 'Processing function: ' + func
+ print('Processing function: ' + func, file=sys.stderr)
for l in scrubbed_body.splitlines():
- print >>sys.stderr, ' ' + l
+ print(' ' + l, file=sys.stderr)
for prefix in prefixes:
if func in func_dict[prefix] and func_dict[prefix][func] != scrubbed_body:
if prefix == prefixes[-1]:
- print >>sys.stderr, ('WARNING: Found conflicting asm under the '
- 'same prefix: %r!' % (prefix,))
+ print('WARNING: Found conflicting asm under the '
+ 'same prefix: %r!' % (prefix,), file=sys.stderr)
else:
func_dict[prefix][func] = None
continue