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:37 UTC

[buildstream] 06/20: import_cas.py: More work on test

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 3ea7fca92cf18d79fccc1a3a20e4ce87fbca47c7
Author: Jim MacArthur <ji...@codethink.co.uk>
AuthorDate: Fri Sep 14 15:42:34 2018 +0100

    import_cas.py: More work on test
---
 tests/storage/import_cas.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tests/storage/import_cas.py b/tests/storage/import_cas.py
index e77328d..d7db43c 100644
--- a/tests/storage/import_cas.py
+++ b/tests/storage/import_cas.py
@@ -11,7 +11,7 @@ TOP_DIR = os.path.dirname(os.path.realpath(__file__))
 
 class FakeContext():
     def __init__(self):
-        self.config_cache_quota = "0"
+        self.config_cache_quota = "65536"
 
     def get_projects(self):
         return []
@@ -21,6 +21,8 @@ root_filesets = [
     [('a/b/c/textfile1', 'This is the replacement textfile 1\n')],
 ]
 
+empty_hash_ref = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
+
 
 def generate_import_roots(directory):
     for fileset in [1, 2]:
@@ -28,9 +30,9 @@ def generate_import_roots(directory):
 
         for (path, content) in root_filesets[fileset - 1]:
             (dirnames, filename) = os.path.split(path)
-            os.path.mkdirs(dirnames)
+            os.makedirs(os.path.join(directory, "content", rootname, dirnames))
 
-            with open(os.path.join(tmpdir, rootname, dirnames, filename), "wt") as f:
+            with open(os.path.join(directory, "content", rootname, dirnames, filename), "wt") as f:
                 f.write(content)
 
 
@@ -38,12 +40,16 @@ def test_cas_import(cli, tmpdir):
     fake_context = FakeContext()
     fake_context.artifactdir = tmpdir
     # Create some fake content
+    generate_import_roots(tmpdir)
+
     d = CasBasedDirectory(fake_context)
     d.import_files(os.path.join(tmpdir, "content", "root1"))
+    assert d.ref.hash != empty_hash_ref
 
     d2 = CasBasedDirectory(fake_context)
     d2.import_files(os.path.join(tmpdir, "content", "root2"))
-
+    assert d2.ref.hash != empty_hash_ref
+    print("D2 hash is {}".format(d2.ref.hash))
     d.import_files(d2)
 
     d.export_files(os.path.join(tmpdir, "output"))