diff options
author | Tom Pollard <tom.pollard@codethink.co.uk> | 2019-12-11 17:54:12 +0000 |
---|---|---|
committer | Tom Pollard <tom.pollard@codethink.co.uk> | 2020-01-21 11:17:59 +0000 |
commit | 451ba255f6337d08f8a3eea39877ffad039e38fd (patch) | |
tree | 8ec91d43642db18ef7e4e26e4d53108b67ca9260 /tests | |
parent | 35dd0e0e9ee1732bef1ff508e12c17b11aa3002a (diff) | |
download | buildstream-451ba255f6337d08f8a3eea39877ffad039e38fd.tar.gz |
_frontend/cli.py: Make show() --use-buildtree respect pull semantics
Ensure that if a buildtree isn't cached locally, it's only fetched
if --pull and pull-buildtrees config are set. Also, only attempt to
fetch if it's plausible that it could be pulled, with appropriate
messaging based on local cached state.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/shellbuildtrees.py | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/tests/integration/shellbuildtrees.py b/tests/integration/shellbuildtrees.py index d3191870a..a3e7da1c2 100644 --- a/tests/integration/shellbuildtrees.py +++ b/tests/integration/shellbuildtrees.py @@ -251,15 +251,17 @@ def test_buildtree_options(cli, tmpdir, datafiles): # Check correctly handling the lack of buildtree, with 'try' not attempting to # pull the buildtree as the user context is by default set to not pull them + # and --pull not given res = cli.run( project=project, args=["shell", "--build", element_name, "--use-buildtree", "try", "--", "cat", "test"] ) assert "Hi" not in res.output assert "Attempting to fetch missing artifact buildtrees" not in res.stderr + assert "WARNING: buildtree is not cached locally, shell will be loaded without it" in res.stderr # Check correctly handling the lack of buildtree, with 'try' attempting and succeeding # to pull the buildtree as the user context allow the pulling of buildtrees and it is - # available in the remote + # available in the remote and --pull given res = cli.run( project=project, args=[ @@ -267,6 +269,7 @@ def test_buildtree_options(cli, tmpdir, datafiles): "shell", "--build", element_name, + "--pull", "--use-buildtree", "try", "--", @@ -281,19 +284,22 @@ def test_buildtree_options(cli, tmpdir, datafiles): assert cli.get_element_state(project, element_name) != "cached" # Check it's not loading the shell at all with always set for the buildtree, when the - # user context does not allow for buildtree pulling + # user context does not allow for buildtree pulling and --pull is not given result = cli.run(project=project, args=["artifact", "pull", "--deps", "all", element_name]) result.assert_success() res = cli.run( project=project, args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "cat", "test"] ) res.assert_main_error(ErrorDomain.APP, None) - assert "Buildtree is not cached locally or in available remotes" in res.stderr + assert ( + "Artifact has a buildtree but it isn't cached. Can be retried with --pull and pull-buildtrees configured" + in res.stderr + ) assert "Hi" not in res.output assert "Attempting to fetch missing artifact buildtree" not in res.stderr # Check that when user context is set to pull buildtrees and a remote has the buildtree, - # 'always' will attempt and succeed at pulling the missing buildtree. + # 'always' will attempt and succeed at pulling the missing buildtree with --pull set. res = cli.run( project=project, args=[ @@ -301,6 +307,7 @@ def test_buildtree_options(cli, tmpdir, datafiles): "shell", "--build", element_name, + "--pull", "--use-buildtree", "always", "--", @@ -309,7 +316,9 @@ 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 ( + "buildtree is not cached locally but did exist, will attempt to pull from available remotes" in res.stderr + ) assert "Attempting to fetch missing artifact buildtree" in res.stderr @@ -332,7 +341,17 @@ def test_pull_buildtree_pulled(cli, tmpdir, datafiles): 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 + # Check it's not using the cached build tree, because --pull + # and pull-buildtrees were not both set + res = cli.run( + project=project, + args=["shell", "--build", element_name, "--pull", "--use-buildtree", "always", "--", "cat", "test",], + ) + res.assert_main_error(ErrorDomain.APP, None) + assert "Artifact not cached locally. Can be retried with --pull and pull-buildtrees configured" in res.stderr + + # Check it's using the cached build tree, because --pull + # and pull-buildtrees were both set res = cli.run( project=project, args=[ @@ -348,4 +367,5 @@ def test_pull_buildtree_pulled(cli, tmpdir, datafiles): "test", ], ) - res.assert_success() + result.assert_success() + assert "Hi" in res.output |