summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim MacArthur <jim.macarthur@codethink.co.uk>2018-09-16 15:59:08 +0100
committerJim MacArthur <jim.macarthur@codethink.co.uk>2018-09-19 16:16:28 +0100
commitf3d4d1cdbe1d285adffa2c47374013a54a136d01 (patch)
tree50b6157814153a4b60a8ff075f55058531bac437
parent3503004a399df3c9fda9b81e24c425b72b9b6d9d (diff)
downloadbuildstream-f3d4d1cdbe1d285adffa2c47374013a54a136d01.tar.gz
import_cas.py: Generate all filesets
-rw-r--r--tests/storage/import_cas.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/storage/import_cas.py b/tests/storage/import_cas.py
index d66ac7693..0e73bea15 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):