You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:38:42 UTC

[buildstream] 11/20: import_cas.py: Generate all filesets

This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch jmac/virtual_directory_tests
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit f3d4d1cdbe1d285adffa2c47374013a54a136d01
Author: Jim MacArthur <ji...@codethink.co.uk>
AuthorDate: Sun Sep 16 15:59:08 2018 +0100

    import_cas.py: Generate all filesets
---
 tests/storage/import_cas.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tests/storage/import_cas.py b/tests/storage/import_cas.py
index d66ac76..0e73bea 100644
--- a/tests/storage/import_cas.py
+++ b/tests/storage/import_cas.py
@@ -27,23 +27,25 @@ empty_hash_ref = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8
 
 
 def generate_import_roots(directory):
-    for fileset in [1, 2]:
+    for fileset in range(1, len(root_filesets) + 1):
         rootname = "root{}".format(fileset)
         rootdir = os.path.join(directory, "content", rootname)
 
         for (path, typesymbol, content) in root_filesets[fileset - 1]:
             if typesymbol == 'F':
                 (dirnames, filename) = os.path.split(path)
-                os.makedirs(os.path.join(rootdir, dirnames))
+                os.makedirs(os.path.join(rootdir, dirnames), exist_ok=True)
 
                 with open(os.path.join(rootdir, dirnames, filename), "wt") as f:
                     f.write(content)
             elif typesymbol == 'D':
-                os.makedirs(os.path.join(rootdir, path))
+                os.makedirs(os.path.join(rootdir, path), exist_ok=True)
             elif typesymbol == 'S':
                 (dirnames, filename) = os.path.split(path)
-                os.makedirs(os.path.join(rootdir, dirnames))
-                os.symlink(content, path)
+                print("Ensuring the existence of {}".format(os.path.join(rootdir, dirnames)))
+                os.makedirs(os.path.join(rootdir, dirnames), exist_ok=True)
+                print("attempting to make a symlink called {} pointing to {}".format(path, content))
+                os.symlink(content, os.path.join(rootdir, path))
 
 
 def file_contents(path):