From 1264347efc120730b5efd0a6126d99805880941d Mon Sep 17 00:00:00 2001 From: Raoul Hidalgo Charman Date: Mon, 17 Jun 2019 15:19:22 +0100 Subject: tests: Add case for using pull and use buildtrees Part of #1044 --- tests/integration/shellbuildtrees.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/integration/shellbuildtrees.py b/tests/integration/shellbuildtrees.py index b48f4afe7..a1eecb1eb 100644 --- a/tests/integration/shellbuildtrees.py +++ b/tests/integration/shellbuildtrees.py @@ -305,3 +305,32 @@ def test_buildtree_options(cli, tmpdir, datafiles): assert 'Hi' in res.output assert "buildtree is not cached locally, will attempt to pull from available remotes" in res.stderr assert 'Attempting to fetch missing artifact buildtree' in res.stderr + + +# Tests running pull and pull-buildtree options at the same time. +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox') +def test_pull_buildtree_pulled(cli, tmpdir, datafiles): + project = str(datafiles) + element_name = 'build-shell/buildtree.bst' + + with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share: + # Build the element to push it to cache + cli.configure({ + 'artifacts': {'url': share.repo, 'push': True} + }) + result = cli.run(project=project, args=['--cache-buildtrees', 'always', 'build', element_name]) + result.assert_success() + assert cli.get_element_state(project, element_name) == 'cached' + + # Discard the cache + shutil.rmtree(str(os.path.join(str(tmpdir), 'cache', 'cas'))) + shutil.rmtree(str(os.path.join(str(tmpdir), 'cache', 'artifacts'))) + assert cli.get_element_state(project, element_name) != 'cached' + + # Check it's using the cached build tree + res = cli.run(project=project, args=[ + '--pull-buildtrees', 'shell', '--build', element_name, '--pull', + '--use-buildtree', 'always', '--', 'cat', 'test' + ]) + res.assert_success() -- cgit v1.2.1