diff options
author | Jürg Billeter <j@bitron.ch> | 2017-07-13 07:22:42 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2017-07-14 14:13:51 +0200 |
commit | 2b4e3d2f9c9b2a00011a815a19276c5419a6e702 (patch) | |
tree | 4598554e74cbac9d9348d0b10c54954f9b3bb798 | |
parent | 08be7e5eb755ec4be5f6ff5c77182a617aa7c4ef (diff) | |
download | buildstream-2b4e3d2f9c9b2a00011a815a19276c5419a6e702.tar.gz |
tests/artifactcache: Store cache keys as artifact metadata
-rw-r--r-- | tests/artifactcache/basics.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/artifactcache/basics.py b/tests/artifactcache/basics.py index 741667c56..62afb16d7 100644 --- a/tests/artifactcache/basics.py +++ b/tests/artifactcache/basics.py @@ -2,8 +2,9 @@ import os import pytest import tempfile -from buildstream import Context, Project +from buildstream import Context, Project, _yaml from buildstream.exceptions import _ArtifactError +from buildstream.element import _KeyStrength from buildstream._artifactcache import ArtifactCache from buildstream._pipeline import Pipeline @@ -38,12 +39,25 @@ def test_empty_extract(pipeline): def build_commit(pipeline): os.makedirs(pipeline.context.builddir, exist_ok=True) with tempfile.TemporaryDirectory(dir=pipeline.context.builddir) as builddir: + filesdir = os.path.join(builddir, 'files') + metadir = os.path.join(builddir, 'meta') + os.mkdir(filesdir) + os.mkdir(metadir) + # create file as mock build output - bindir = os.path.join(builddir, 'bin') + bindir = os.path.join(filesdir, 'bin') os.mkdir(bindir) with open(os.path.join(bindir, 'baz'), 'w') as f: f.write('hello, world') + meta = { + 'keys': { + 'strong': pipeline.target._get_cache_key(_KeyStrength.STRONG), + 'weak': pipeline.target._get_cache_key(_KeyStrength.WEAK), + } + } + _yaml.dump(_yaml.node_sanitize(meta), os.path.join(metadir, 'artifact.yaml')) + # commit build output to artifact cache pipeline.artifacts.commit(pipeline.target, builddir) pipeline.target._cached(recalculate=True) @@ -55,7 +69,8 @@ def test_commit_extract(pipeline): # extract artifact and verify the content extractdir = pipeline.artifacts.extract(pipeline.target) - with open(os.path.join(extractdir, 'bin', 'baz'), 'r') as f: + filesdir = os.path.join(extractdir, 'files') + with open(os.path.join(filesdir, 'bin', 'baz'), 'r') as f: content = f.read() assert(content == 'hello, world') |