[commit: ghc] master: Testsuite: *do* replace backslashes in config.libdir (1ddc10b)

git at git.haskell.org git at git.haskell.org
Mon Jun 20 14:37:13 UTC 2016


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

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

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

commit 1ddc10bb405e0f88584784bd42f5bdd5ded24dcf
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Mon Jun 20 00:54:38 2016 +0200

    Testsuite: *do* replace backslashes in config.libdir
    
    See `Note [Replacing backward slashes in config.libdir]`
    
    There is one caveat: in ae4acbd1ba4168b867a1b5fe8de50c0199dfc1f4
    I mentioned:
    
      > Changing backwards slashes to forward slashes apparently confuses
      > msys2/mingw magic path handling.
    
    I can not reproduce that problem anymore, however.
    
    This patch validates for me, and fixes all tests that use config.libdir
    for WAY=ghci. We'll see how it goes.


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

1ddc10bb405e0f88584784bd42f5bdd5ded24dcf
 testsuite/config/ghc | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/testsuite/config/ghc b/testsuite/config/ghc
index 3be803d..cf9a7ba 100644
--- a/testsuite/config/ghc
+++ b/testsuite/config/ghc
@@ -173,7 +173,8 @@ def get_compiler_info():
     s = re.sub('[\r\n]', '', s)
     rtsInfoDict = dict(eval(s))
 
-    config.libdir = compilerInfoDict['LibDir']
+    # See Note [Replacing backward slashes in config.libdir].
+    config.libdir = compilerInfoDict['LibDir'].replace('\\', '/')
 
     v = compilerInfoDict["Project version"]
     config.compiler_version = v
@@ -224,3 +225,35 @@ def get_compiler_info():
         config.plugin_way_flags = "-static"
         config.ghc_th_way       = "normal"
         config.ghc_plugin_way   = "normal"
+
+# Note [Replacing backward slashes in config.libdir]
+# 
+# We *do* need to replace backslashes in config.libdir, for the following
+# reason:
+#
+# * Tests use config.libdir as follows:
+#
+#     extra_run_opts('"' + config.libdir + '"')
+#
+#   The double quotes are there because config.libdir might contain
+#   spaces.
+#
+# * This string is then written /as is/ to <testname>.genscript in
+#   testlib.interpreter_run:
+#
+#     script.write(':set args ' + opts.extra_run_opts + '\n')
+#
+# * But GHCi expects the arguments to ':set args' to be proper Haskell
+#   strings (when they are quoted), with backslashes escaped. Since
+#   config.libdir contains single backslash characters, tests such as T5313
+#   will fail for WAY=ghci with "Pattern match failure in do expression".
+#
+# Arguably the above code for writing `:set args` should be smarter. This
+# is tricky to get right though, because in GHCI `:set args foo\bar` (no
+# double quotes) works perfectly fine, and is interpreted as the Haskell
+# string "foo\\bar". Therfore, simply escaping all backward slashes in
+# opts.extra_run_opts before concatenating it with ':set args' is not right
+# either.
+#
+# Replacing backslashes to forward slashes in config.libdir works around the
+# problem.



More information about the ghc-commits mailing list