summaryrefslogtreecommitdiff
path: root/testsuite/driver
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2016-11-02 14:58:30 -0400
committerBen Gamari <ben@smart-cactus.org>2016-11-02 15:42:00 -0400
commitcc4710af723ca4bbcf77172ff715af22f9ce8419 (patch)
treef0205a36cd0f0cb39ba45401f5d12de03b47efb4 /testsuite/driver
parent8a5960ad874d31fcf631b4d427ccd9fae571745c (diff)
downloadhaskell-cc4710af723ca4bbcf77172ff715af22f9ce8419.tar.gz
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
Diffstat (limited to 'testsuite/driver')
-rw-r--r--testsuite/driver/runtests.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py
index f36725efd5..c97323b810 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