]> granicus.if.org Git - llvm/commitdiff
Fix update_mir_test_checks.py to run on python3
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 2 Mar 2019 11:14:01 +0000 (11:14 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 2 Mar 2019 11:14:01 +0000 (11:14 +0000)
Split off from D58817

Differential Revision: https://reviews.llvm.org/D58820

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355268 91177308-0d34-0410-b5e6-96231b3b80d8

utils/update_mir_test_checks.py

index 56d236de24915271e12e206640c57e6ef1f62647..cf7528f57609708a7867d91e8094789c9cf1c674 100755 (executable)
@@ -62,6 +62,8 @@ class LLC:
         with open(ir) as ir_file:
             stdout = subprocess.check_output('{} {}'.format(self.bin, 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
@@ -408,7 +410,7 @@ def update_test_file(llc, test, remove_common_prefixes=False, verbose=False):
     log('Writing {} lines to {}...'.format(len(output_lines), test), verbose)
 
     with open(test, 'wb') as fd:
-        fd.writelines([l + '\n' for l in output_lines])
+        fd.writelines(['{}\n'.format(l).encode('utf-8') for l in output_lines])
 
 
 def main():