[commit: ghc] master: Make testsuite work again with Py3 (3221599)

git at git.haskell.org git at git.haskell.org
Wed Dec 23 21:59:21 UTC 2015


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

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

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

commit 32215996528779f71a636350a36c01a8b3ccb1bf
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Wed Dec 23 22:37:42 2015 +0100

    Make testsuite work again with Py3
    
    Python 3 support seems to have mildly bitrotten since #9184 was closed.
    Luckily, only some minor tweaks seem necessary.


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

32215996528779f71a636350a36c01a8b3ccb1bf
 testsuite/driver/testlib.py  | 11 ++++++++---
 testsuite/driver/testutil.py |  2 +-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 4e9a1fb..33e134d 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -23,6 +23,11 @@ import subprocess
 from testglobals import *
 from testutil import *
 
+try:
+    basestring
+except: # Python 3
+    basestring = (str,bytes)
+
 if config.use_threads:
     import threading
     try:
@@ -691,8 +696,8 @@ def test_common_work (name, opts, func, args):
         elif config.speed > 0:
             # However, if we EXPLICITLY asked for a way (with extra_ways)
             # please test it!
-            explicit_ways = filter(lambda way: way in opts.extra_ways, do_ways)
-            other_ways = filter(lambda way: way not in opts.extra_ways, do_ways)
+            explicit_ways = list(filter(lambda way: way in opts.extra_ways, do_ways))
+            other_ways = list(filter(lambda way: way not in opts.extra_ways, do_ways))
             do_ways = other_ways[:1] + explicit_ways
 
         if not config.clean_only:
@@ -1721,7 +1726,7 @@ def normalise_errmsg( str ):
     # Also filter out bullet characters.  This is because bullets are used to
     # separate error sections, and tests shouldn't be sensitive to how the
     # the division happens.
-    bullet = u'•'.encode('utf8')
+    bullet = u'•'.encode('utf8') if isinstance(str, bytes) else u'•'
     str = str.replace(bullet, '')
     return str
 
diff --git a/testsuite/driver/testutil.py b/testsuite/driver/testutil.py
index 2f037f0..029a3b6 100644
--- a/testsuite/driver/testutil.py
+++ b/testsuite/driver/testutil.py
@@ -33,6 +33,6 @@ def getStdout(cmd_and_args):
     r = p.wait()
     if r != 0:
         raise Exception("Command failed: " + str(cmd_and_args))
-    if stderr != '':
+    if stderr:
         raise Exception("stderr from command: " + str(cmd_and_args))
     return stdout



More information about the ghc-commits mailing list