summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorTom Pollard <tom.pollard@codethink.co.uk>2019-06-11 10:47:37 +0100
committerTom Pollard <tom.pollard@codethink.co.uk>2019-06-19 13:33:44 +0100
commita02cf9c14022b49d26bde7cf73369e11158d3d6b (patch)
tree66aa97003eb14de9c75577620bb0750b1aea3e65 /tests/integration
parent9d593e1f3449dc8f24fb6855264f78882b182e3c (diff)
downloadbuildstream-a02cf9c14022b49d26bde7cf73369e11158d3d6b.tar.gz
_frontend/cli.py: Tweak 'try' & 'always' bst shell buildtree handling
If the cached Artifact wasn't originally generated with a buildtree, then there's no need to attempt to find it in remotes by entering Stream(). In interactive mode we only present the user the option to attempt the pull with the above assumption on buildtree_exists, so apply the same to applicable non interactive choices. This also includes some tweaks in integration/shellbuildtrees.py to reflect changes and cover cases that were missing.
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/shellbuildtrees.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/tests/integration/shellbuildtrees.py b/tests/integration/shellbuildtrees.py
index e53003757..b48f4afe7 100644
--- a/tests/integration/shellbuildtrees.py
+++ b/tests/integration/shellbuildtrees.py
@@ -59,13 +59,13 @@ def test_buildtree_staged_forced_true(cli_integration, datafiles):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
-def test_buildtree_staged_warn_empty_cached(cli_integration, tmpdir, datafiles):
- # Test that if we stage a cached and empty buildtree, we warn the user.
+def test_buildtree_staged_warn_non_cached(cli_integration, tmpdir, datafiles):
+ # Test that if we attempt to stage a buildtree that was never cached, we warn the user.
project = str(datafiles)
element_name = 'build-shell/buildtree.bst'
# Switch to a temp artifact cache dir to ensure the artifact is rebuilt,
- # caching an empty buildtree
+ # without caching a buildtree which is the default bst behaviour
cli_integration.configure({
'cachedir': str(tmpdir)
})
@@ -77,7 +77,15 @@ def test_buildtree_staged_warn_empty_cached(cli_integration, tmpdir, datafiles):
'shell', '--build', '--use-buildtree', 'always', element_name, '--', 'cat', 'test'
])
res.assert_main_error(ErrorDomain.APP, None)
- assert "Artifact was created without buildtree" in res.stderr
+ assert "Artifact was created without buildtree, unable to launch shell with it" in res.stderr
+
+ # Now attempt the same with the try option, this should not attempt to find a buildtree
+ # and just launch the shell, however the cat should still fail.
+ res = cli_integration.run(project=project, args=[
+ 'shell', '--build', '--use-buildtree', 'try', element_name, '--', 'cat', 'test'
+ ])
+ assert "Artifact created without buildtree, shell will be loaded without it" in res.stderr
+ assert 'Hi' not in res.output
@pytest.mark.datafiles(DATA_DIR)
@@ -142,7 +150,7 @@ def test_buildtree_from_failure_option_never(cli_integration, tmpdir, datafiles)
element_name = 'build-shell/buildtree-fail.bst'
# Switch to a temp artifact cache dir to ensure the artifact is rebuilt,
- # caching an empty buildtree
+ # without caching a buildtree explicitly
cli_integration.configure({
'cachedir': str(tmpdir)
})
@@ -154,7 +162,7 @@ def test_buildtree_from_failure_option_never(cli_integration, tmpdir, datafiles)
'shell', '--build', element_name, '--use-buildtree', 'always', '--', 'cat', 'test'
])
res.assert_main_error(ErrorDomain.APP, None)
- assert "Artifact was created without buildtree" in res.stderr
+ assert "Artifact was created without buildtree, unable to launch shell with it" in res.stderr
@pytest.mark.datafiles(DATA_DIR)
@@ -264,8 +272,6 @@ def test_buildtree_options(cli, tmpdir, datafiles):
])
assert 'Hi' not in res.output
assert 'Attempting to fetch missing artifact buildtrees' not in res.stderr
- assert """Buildtree is not cached locally or in available remotes,
- shell will be loaded without it"""
# 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
@@ -297,4 +303,5 @@ def test_buildtree_options(cli, tmpdir, datafiles):
'--pull-buildtrees', 'shell', '--build', element_name, '--use-buildtree', 'always', '--', 'cat', 'test'
])
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