[commit: ghc] master: testsuite/driver: Never symlink on Windows (8bb960e)

git at git.haskell.org git at git.haskell.org
Mon Oct 17 19:02:42 UTC 2016


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

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

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

commit 8bb960eff05ef8171ce2632a62db89b4e96aff74
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Sun Oct 16 20:49:00 2016 -0400

    testsuite/driver: Never symlink on Windows
    
    While msys' mingw Python 3 does indeed export `os.symlink`, it is
    unusable since creating symbolic links on Windows requires permissions
    that essentially no one has.
    
    Test Plan: Validate on Windows
    
    Reviewers: austin, Phyx, thomie
    
    Differential Revision: https://phabricator.haskell.org/D2604


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

8bb960eff05ef8171ce2632a62db89b4e96aff74
 testsuite/driver/testutil.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/testsuite/driver/testutil.py b/testsuite/driver/testutil.py
index 2862a44..b4159d1 100644
--- a/testsuite/driver/testutil.py
+++ b/testsuite/driver/testutil.py
@@ -1,5 +1,6 @@
 import errno
 import os
+import platform
 import subprocess
 import shutil
 
@@ -44,9 +45,14 @@ def lndir(srcdir, dstdir):
             os.mkdir(dst)
             lndir(src, dst)
 
-# On Windows, os.symlink is not defined. Except when using msys2, as ghc
-# does. Then it copies the source file, instead of creating a symbolic
-# link to it. We define the following function to make this magic more
-# explicit/discoverable. You are enouraged to use it instead of
-# os.symlink.
-link_or_copy_file = getattr(os, "symlink", shutil.copyfile)
+# On Windows, os.symlink is not defined with Python 2.7, but is in Python 3
+# when using msys2, as GHC does. Unfortunately, only Administrative users have
+# the privileges necessary to create symbolic links by default. Consequently we
+# are forced to just copy instead.
+#
+# We define the following function to make this magic more
+# explicit/discoverable. You are enouraged to use it instead of os.symlink.
+if platform.system() == 'Windows':
+    link_or_copy_file = shutil.copyfile
+else:
+    link_or_copy_file = os.symlink



More information about the ghc-commits mailing list