During source manager test, write back the file using binary mode.
authorZachary Turner <zturner@google.com>
Thu, 15 Jan 2015 22:53:44 +0000 (22:53 +0000)
committerZachary Turner <zturner@google.com>
Thu, 15 Jan 2015 22:53:44 +0000 (22:53 +0000)
On Windows, opening with "w" opens it as text instead of binary.
This causes translation of newline characters, so that "\n" turns
into "\r\n", which in turn leads to git detecting that the file
has changed and wanting to commit it.

llvm-svn: 226220

lldb/test/source-manager/TestSourceManager.py

index c4634b8..5be75cb 100644 (file)
@@ -155,7 +155,7 @@ class SourceManagerTestCase(TestBase):
         def restore_file():
             #print "os.path.getmtime() before restore:", os.path.getmtime('main.c')
             time.sleep(1)
-            with open('main.c', 'w') as f:
+            with open('main.c', 'wb') as f:
                 f.write(original_content)
             if self.TraceOn():
                 with open('main.c', 'r') as f:
@@ -168,7 +168,7 @@ class SourceManagerTestCase(TestBase):
 
 
         # Modify the source code file.
-        with open('main.c', 'w') as f:
+        with open('main.c', 'wb') as f:
             time.sleep(1)
             f.write(new_content)
             if self.TraceOn():