[commit: ghc] master: testsuite: Simplify kernel32 glue logic (cc4710a)

git at git.haskell.org git at git.haskell.org
Wed Nov 2 20:15:09 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/cc4710af723ca4bbcf77172ff715af22f9ce8419/ghc

>---------------------------------------------------------------

commit cc4710af723ca4bbcf77172ff715af22f9ce8419
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Wed Nov 2 14:58:30 2016 -0400

    testsuite: Simplify kernel32 glue logic
    
    On Windows the testsuite driver calls kernel32 to set the current
    terminal codepage. The previous implementation of this was significantly
    more complex than necessary, and was wrong in the case of MSYS2, which
    requires that we explicitly load the library using the name of its
    DLL, including its file extension.
    
    Test Plan: Validate on Windows
    
    Reviewers: austin, RyanGlScott, Phyx
    
    Reviewed By: RyanGlScott, Phyx
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2641
    
    GHC Trac Issues: #12661


>---------------------------------------------------------------

cc4710af723ca4bbcf77172ff715af22f9ce8419
 testsuite/driver/runtests.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py
index f36725e..c97323b 100644
--- a/testsuite/driver/runtests.py
+++ b/testsuite/driver/runtests.py
@@ -160,17 +160,18 @@ if windows:
 if windows:
     import ctypes
     # Windows and mingw* Python provide windll, msys2 python provides cdll.
-    if hasattr(ctypes, 'windll'):
-        mydll = ctypes.windll
+    if hasattr(ctypes, 'WinDLL'):
+        mydll = ctypes.WinDLL
     else:
-        mydll = ctypes.cdll
+        mydll = ctypes.CDLL
 
     # This actually leaves the terminal in codepage 65001 (UTF8) even
     # after python terminates. We ought really remember the old codepage
     # and set it back.
-    if mydll.kernel32.SetConsoleCP(65001) == 0:
+    kernel32 = mydll('kernel32.dll')
+    if kernel32.SetConsoleCP(65001) == 0:
         raise Exception("Failure calling SetConsoleCP(65001)")
-    if mydll.kernel32.SetConsoleOutputCP(65001) == 0:
+    if kernel32.SetConsoleOutputCP(65001) == 0:
         raise Exception("Failure calling SetConsoleOutputCP(65001)")
 else:
     # Try and find a utf8 locale to use



More information about the ghc-commits mailing list