[commit: ghc] wip/merge: The test runner now also works under the msys-native Python. (a41ceac)

git at git.haskell.org git at git.haskell.org
Wed Nov 19 04:27:45 UTC 2014


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

On branch  : wip/merge
Link       : http://ghc.haskell.org/trac/ghc/changeset/a41ceacfe5889c16b3f4ac07ef53aeb81c230743/ghc

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

commit a41ceacfe5889c16b3f4ac07ef53aeb81c230743
Author: Gintautas Miliauskas <gintautas.miliauskas at gmail.com>
Date:   Mon Sep 22 23:10:56 2014 +0200

    The test runner now also works under the msys-native Python.
    
    Msys binaries apply heuristics to escape paths in arguments intended for
    non-msys binaries, which breaks timeout invocations, see #9626.
    
    Signed-off-by: Austin Seipp <austin at well-typed.com>


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

a41ceacfe5889c16b3f4ac07ef53aeb81c230743
 testsuite/driver/testlib.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 1549381..6fc86e4 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -1780,9 +1780,25 @@ def rawSystem(cmd_and_args):
     else:
         return os.spawnv(os.P_WAIT, cmd_and_args[0], cmd_and_args)
 
+# When running under native msys Python, any invocations of non-msys binaries,
+# including timeout.exe, will have their arguments munged according to some
+# heuristics, which leads to malformed command lines (#9626).  The easiest way
+# to avoid problems is to invoke through /usr/bin/cmd which sidesteps argument
+# munging because it is a native msys application.
+def passThroughCmd(cmd_and_args):
+    args = []
+    # cmd needs a Windows-style path for its first argument.
+    args.append(cmd_and_args[0].replace('/', '\\'))
+    # Other arguments need to be quoted to deal with spaces.
+    args.extend(['"%s"' % arg for arg in cmd_and_args[1:]])
+    return ["cmd", "/c", " ".join(args)]
+
 # Note that this doesn't handle the timeout itself; it is just used for
 # commands that have timeout handling built-in.
 def rawSystemWithTimeout(cmd_and_args):
+    if config.os == 'mingw32' and sys.executable.startswith('/usr'):
+        # This is only needed when running under msys python.
+        cmd_and_args = passThroughCmd(cmd_and_args)
     r = rawSystem(cmd_and_args)
     if r == 98:
         # The python timeout program uses 98 to signal that ^C was pressed



More information about the ghc-commits mailing list