summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py
diff options
context:
space:
mode:
authorAdrian McCarthy <amccarth@google.com>2016-01-25 19:13:35 +0000
committerAdrian McCarthy <amccarth@google.com>2016-01-25 19:13:35 +0000
commit60897300c5dd2bfcf0677c4746acda78a0093126 (patch)
tree997b8a100bf20fd4d6266b1d4dfb574a24461895 /lldb/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py
parenta392810bea652716c660af509035e178cee75a6b (diff)
downloadbcm5719-llvm-60897300c5dd2bfcf0677c4746acda78a0093126.tar.gz
bcm5719-llvm-60897300c5dd2bfcf0677c4746acda78a0093126.zip
Fix TestSourceManager.py on Windows.
Python 3.5 is picky about writing strings to binary files, so we now open the file in text mode, and we explicitly set the newline mode to avoid re-writing it with CR+LF on Windows (which causes git to think the file had changed). llvm-svn: 258704
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py b/lldb/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py
index b4e7541a709..3b7dd8c8bce 100644
--- a/lldb/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py
+++ b/lldb/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py
@@ -80,13 +80,13 @@ class SourceManagerTestCase(TestBase):
main_c_hidden = os.path.join("hidden", main_c)
os.rename(main_c, main_c_hidden)
+ # Restore main.c after the test.
+ self.addTearDownHook(lambda: os.rename(main_c_hidden, main_c))
+
if self.TraceOn():
system([["ls"]])
system([["ls", "hidden"]])
- # Restore main.c after the test.
- self.addTearDownHook(lambda: os.rename(main_c_hidden, main_c))
-
# Set target.source-map settings.
self.runCmd("settings set target.source-map %s %s" % (os.getcwd(), os.path.join(os.getcwd(), "hidden")))
# And verify that the settings work.
@@ -133,7 +133,7 @@ class SourceManagerTestCase(TestBase):
self.assertTrue(int(m.group(1)) > 0)
# Read the main.c file content.
- with open('main.c', 'r') as f:
+ with io.open('main.c', 'r', newline='\n') as f:
original_content = f.read()
if self.TraceOn():
print("original content:", original_content)
@@ -145,7 +145,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', 'wb') as f:
+ with io.open('main.c', 'w', newline='\n') as f:
f.write(original_content)
if self.TraceOn():
with open('main.c', 'r') as f:
@@ -156,9 +156,8 @@ class SourceManagerTestCase(TestBase):
print("os.path.getmtime() after restore:", os.path.getmtime('main.c'))
-
# Modify the source code file.
- with open('main.c', 'wb') as f:
+ with io.open('main.c', 'w', newline='\n') as f:
time.sleep(1)
f.write(new_content)
if self.TraceOn():
OpenPOWER on IntegriCloud