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:41 UTC
[buildstream] 10/20: import_cas: Add some more files and
directory/symlink support
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 3503004a399df3c9fda9b81e24c425b72b9b6d9d
Author: Jim MacArthur <ji...@codethink.co.uk>
AuthorDate: Sun Sep 16 13:29:46 2018 +0100
import_cas: Add some more files and directory/symlink support
---
tests/storage/import_cas.py | 36 ++++++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 10 deletions(-)
diff --git a/tests/storage/import_cas.py b/tests/storage/import_cas.py
index 764df80..d66ac76 100644
--- a/tests/storage/import_cas.py
+++ b/tests/storage/import_cas.py
@@ -17,8 +17,10 @@ class FakeContext():
return []
root_filesets = [
- [('a/b/c/textfile1', 'This is textfile 1\n')],
- [('a/b/c/textfile1', 'This is the replacement textfile 1\n')],
+ [('a/b/c/textfile1', 'F', 'This is textfile 1\n')],
+ [('a/b/c/textfile1', 'F', 'This is the replacement textfile 1\n')],
+ [('a/b/d', 'D', '')],
+ [('a/b/d', 'D', ''), ('a/b/c', 'S', '/a/b/d')]
]
empty_hash_ref = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
@@ -27,19 +29,33 @@ empty_hash_ref = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8
def generate_import_roots(directory):
for fileset in [1, 2]:
rootname = "root{}".format(fileset)
+ rootdir = os.path.join(directory, "content", rootname)
- for (path, content) in root_filesets[fileset - 1]:
- (dirnames, filename) = os.path.split(path)
- os.makedirs(os.path.join(directory, "content", rootname, dirnames))
+ 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))
- with open(os.path.join(directory, "content", rootname, dirnames, filename), "wt") as f:
- f.write(content)
+ with open(os.path.join(rootdir, dirnames, filename), "wt") as f:
+ f.write(content)
+ elif typesymbol == 'D':
+ os.makedirs(os.path.join(rootdir, path))
+ elif typesymbol == 'S':
+ (dirnames, filename) = os.path.split(path)
+ os.makedirs(os.path.join(rootdir, dirnames))
+ os.symlink(content, path)
-def file_contents_are(path, contents):
+
+def file_contents(path):
with open(path, "r") as f:
- result = f.read() == contents
+ result = f.read()
return result
+
+def file_contents_are(path, contents):
+ return file_contents(path) == contents
+
+
def test_cas_import(cli, tmpdir):
fake_context = FakeContext()
fake_context.artifactdir = tmpdir
@@ -58,4 +74,4 @@ def test_cas_import(cli, tmpdir):
d.export_files(os.path.join(tmpdir, "output"))
assert os.path.exists(os.path.join(tmpdir, "output", "a", "b", "c", "textfile1"))
- assert file_contents_are(os.path.join(tmpdir, "output", "a", "b", "c", "textfile1"), root_filesets[1][0][1])
+ assert file_contents_are(os.path.join(tmpdir, "output", "a", "b", "c", "textfile1"), root_filesets[1][0][2])