Author: amccarth Date: Mon Jan 25 13:13:35 2016 New Revision: 258704 URL: http://llvm.org/viewvc/llvm-project?rev=258704&view=rev Log: 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). Modified: lldb/trunk/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py Modified: lldb/trunk/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py?rev=258704&r1=258703&r2=258704&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py Mon Jan 25 13:13:35 2016 @@ -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(): _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits