summaryrefslogtreecommitdiff
path: root/tests/artifactcache/junctions.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/artifactcache/junctions.py')
-rw-r--r--tests/artifactcache/junctions.py98
1 files changed, 45 insertions, 53 deletions
diff --git a/tests/artifactcache/junctions.py b/tests/artifactcache/junctions.py
index 12423f937..378d007a0 100644
--- a/tests/artifactcache/junctions.py
+++ b/tests/artifactcache/junctions.py
@@ -2,7 +2,6 @@ import os
import shutil
import pytest
from tests.testutils import cli, create_artifact_share
-from tests.testutils.site import IS_LINUX
from buildstream import _yaml
@@ -37,60 +36,53 @@ def project_set_artifacts(project, url):
_yaml.dump(_yaml.node_sanitize(project_config), filename=project_conf_file)
-@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
@pytest.mark.datafiles(DATA_DIR)
def test_push_pull(cli, tmpdir, datafiles):
project = os.path.join(str(datafiles), 'foo')
base_project = os.path.join(str(project), 'base')
- share = create_artifact_share(os.path.join(str(tmpdir), 'artifactshare-foo'))
- base_share = create_artifact_share(os.path.join(str(tmpdir), 'artifactshare-base'))
-
- # First build it without the artifact cache configured
- result = cli.run(project=project, args=['build', 'target.bst'])
- assert result.exit_code == 0
-
- # Assert that we are now cached locally
- state = cli.get_element_state(project, 'target.bst')
- assert state == 'cached'
- state = cli.get_element_state(base_project, 'target.bst')
- assert state == 'cached'
-
- project_set_artifacts(project, share.repo)
- project_set_artifacts(base_project, base_share.repo)
-
- # Now try bst push
- result = cli.run(project=project, args=['push', '--deps', 'all', 'target.bst'])
- assert result.exit_code == 0
-
- # And finally assert that the artifacts are in the right shares
- assert_shared(cli, share, 'foo', project, 'target.bst')
- assert_shared(cli, base_share, 'base', base_project, 'target.bst')
-
- # Make sure we update the summary in our artifact shares,
- # we dont have a real server around to do it
- #
- share.update_summary()
- base_share.update_summary()
-
- # Now we've pushed, delete the user's local artifact cache
- # directory and try to redownload it from the share
- #
- artifacts = os.path.join(cli.directory, 'artifacts')
- shutil.rmtree(artifacts)
-
- # Assert that nothing is cached locally anymore
- state = cli.get_element_state(project, 'target.bst')
- assert state != 'cached'
- state = cli.get_element_state(base_project, 'target.bst')
- assert state != 'cached'
-
- # Now try bst pull
- result = cli.run(project=project, args=['pull', '--deps', 'all', 'target.bst'])
- assert result.exit_code == 0
-
- # And assert that they are again in the local cache, without having built
- state = cli.get_element_state(project, 'target.bst')
- assert state == 'cached'
- state = cli.get_element_state(base_project, 'target.bst')
- assert state == 'cached'
+ with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare-foo')) as share,\
+ create_artifact_share(os.path.join(str(tmpdir), 'artifactshare-base')) as base_share:
+
+ # First build it without the artifact cache configured
+ result = cli.run(project=project, args=['build', 'target.bst'])
+ assert result.exit_code == 0
+
+ # Assert that we are now cached locally
+ state = cli.get_element_state(project, 'target.bst')
+ assert state == 'cached'
+ state = cli.get_element_state(base_project, 'target.bst')
+ assert state == 'cached'
+
+ project_set_artifacts(project, share.repo)
+ project_set_artifacts(base_project, base_share.repo)
+
+ # Now try bst push
+ result = cli.run(project=project, args=['push', '--deps', 'all', 'target.bst'])
+ assert result.exit_code == 0
+
+ # And finally assert that the artifacts are in the right shares
+ assert_shared(cli, share, 'foo', project, 'target.bst')
+ assert_shared(cli, base_share, 'base', base_project, 'target.bst')
+
+ # Now we've pushed, delete the user's local artifact cache
+ # directory and try to redownload it from the share
+ #
+ artifacts = os.path.join(cli.directory, 'artifacts')
+ shutil.rmtree(artifacts)
+
+ # Assert that nothing is cached locally anymore
+ state = cli.get_element_state(project, 'target.bst')
+ assert state != 'cached'
+ state = cli.get_element_state(base_project, 'target.bst')
+ assert state != 'cached'
+
+ # Now try bst pull
+ result = cli.run(project=project, args=['pull', '--deps', 'all', 'target.bst'])
+ assert result.exit_code == 0
+
+ # And assert that they are again in the local cache, without having built
+ state = cli.get_element_state(project, 'target.bst')
+ assert state == 'cached'
+ state = cli.get_element_state(base_project, 'target.bst')
+ assert state == 'cached'