[utils] Add windows support to update_llc_test_checks.py
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 27 Jan 2016 21:13:18 +0000 (21:13 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 27 Jan 2016 21:13:18 +0000 (21:13 +0000)
Strip dos line endings from llc generated files to allow the regex patterns to match them.

Ensure updated *.ll files are generated with unix style line endings.

llvm-svn: 258987

llvm/utils/update_llc_test_checks.py

index cfdf830..4ce034d 100755 (executable)
@@ -20,6 +20,8 @@ def llc(args, cmd_args, ir):
   with open(ir) as ir_file:
     stdout = subprocess.check_output(args.llc_binary + ' ' + cmd_args,
                                      shell=True, stdin=ir_file)
+  # Fix line endings to unix CR style.
+  stdout = stdout.replace('\r\n', '\n')
   return stdout
 
 
@@ -211,7 +213,7 @@ def main():
     if args.verbose:
       print>>sys.stderr, 'Writing %d fixed lines to %s...' % (
           len(fixed_lines), test)
-    with open(test, 'w') as f:
+    with open(test, 'wb') as f:
       f.writelines([l + '\n' for l in fixed_lines])