switch from copy to symlink
authorVolker Birk <vb@pep.foundation>
Thu, 04 Jan 2018 23:02:04 +0100
changeset 23504725d91aabeb
parent 2349 13085d58b256
child 2351 b59bc7d1baa3
switch from copy to symlink
test/python_tests/test_setup.py
     1.1 --- a/test/python_tests/test_setup.py	Thu Jan 04 22:44:26 2018 +0100
     1.2 +++ b/test/python_tests/test_setup.py	Thu Jan 04 23:02:04 2018 +0100
     1.3 @@ -22,7 +22,7 @@
     1.4  
     1.5  realhome = os.path.expanduser("~")
     1.6  mydir = os.path.abspath(os.path.curdir)
     1.7 -files_to_copy = ("transport.py",)
     1.8 +files_to_link = ("transport.py",)
     1.9  
    1.10  
    1.11  def link_if_exists(dirname, arthome):
    1.12 @@ -49,6 +49,14 @@
    1.13      print(repr(me))
    1.14  
    1.15  
    1.16 +def link_file(filename):
    1.17 +    "sym-link file to version in parent directory"
    1.18 +
    1.19 +    src = os.path.join(os.pardir, filename)
    1.20 +    if not os.path.exists(filename):
    1.21 +        os.symlink(src, filename, False)
    1.22 +
    1.23 +
    1.24  def create_home(mydir, arthome, username):
    1.25      "create an artificial home directory for testing"
    1.26  
    1.27 @@ -56,9 +64,8 @@
    1.28      os.makedirs(arthome, exist_ok=True)
    1.29  
    1.30      os.chdir(arthome)
    1.31 -    for filename in files_to_copy:
    1.32 -        src = os.path.join(os.pardir, filename)
    1.33 -        shutil.copyfile(src, filename)
    1.34 +    for filename in files_to_link:
    1.35 +        link_file(filename)
    1.36  
    1.37      link_if_exists("bin", arthome)
    1.38      link_if_exists("include", arthome)