summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-03-14 10:40:56 +0000
committerJürg Billeter <j@bitron.ch>2019-03-16 07:24:58 +0100
commit142ef9cdc6ed3c5b0e91ca450dfcd608822e0a60 (patch)
treecf803c726ddd833f52fc333d17d340e7c82fb991 /tests
parent3dc95d4ba2bf6c236bc69f35c098f563ab0f65aa (diff)
downloadbuildstream-142ef9cdc6ed3c5b0e91ca450dfcd608822e0a60.tar.gz
_artifact.py: Do not create empty buildtree directories
Creating an empty buildtree directory when buildtree caching is disabled means cached_buildtree() can return True even if no buildtree is available, which breaks logic in the frontend and in Stream. This adds the buildtree_exists() method to indicate whether an artifact was created with a buildtree, independent of whether the buildtree is available in the local cache.
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/artifact.py14
-rw-r--r--tests/integration/shellbuildtrees.py8
2 files changed, 9 insertions, 13 deletions
diff --git a/tests/integration/artifact.py b/tests/integration/artifact.py
index 35e7f56ae..98c6ce13f 100644
--- a/tests/integration/artifact.py
+++ b/tests/integration/artifact.py
@@ -77,23 +77,20 @@ def test_cache_buildtrees(cli, tmpdir, datafiles):
assert cli.get_element_state(project, element_name) == 'cached'
assert share1.has_artifact('test', element_name, cli.get_element_key(project, element_name))
- # The extracted buildtree dir should be empty, as we set the config
- # to not cache buildtrees
+ # The buildtree dir should not exist, as we set the config to not cache buildtrees.
cache_key = cli.get_element_key(project, element_name)
elementdigest = share1.has_artifact('test', element_name, cache_key)
with cas_extract_buildtree(elementdigest) as buildtreedir:
- assert os.path.isdir(buildtreedir)
- assert not os.listdir(buildtreedir)
+ assert not os.path.isdir(buildtreedir)
# Delete the local cached artifacts, and assert the when pulled with --pull-buildtrees
- # that is was cached in share1 as expected with an empty buildtree dir
+ # that is was cached in share1 as expected without a buildtree dir
shutil.rmtree(os.path.join(str(tmpdir), 'cas'))
assert cli.get_element_state(project, element_name) != 'cached'
result = cli.run(project=project, args=['--pull-buildtrees', 'artifact', 'pull', element_name])
assert element_name in result.get_pulled_elements()
with cas_extract_buildtree(elementdigest) as buildtreedir:
- assert os.path.isdir(buildtreedir)
- assert not os.listdir(buildtreedir)
+ assert not os.path.isdir(buildtreedir)
shutil.rmtree(os.path.join(str(tmpdir), 'cas'))
# Assert that the default behaviour of pull to not include buildtrees on the artifact
@@ -148,5 +145,4 @@ def test_cache_buildtrees(cli, tmpdir, datafiles):
cache_key = cli.get_element_key(project, element_name)
elementdigest = share3.has_artifact('test', element_name, cache_key)
with cas_extract_buildtree(elementdigest) as buildtreedir:
- assert os.path.isdir(buildtreedir)
- assert not os.listdir(buildtreedir)
+ assert not os.path.isdir(buildtreedir)
diff --git a/tests/integration/shellbuildtrees.py b/tests/integration/shellbuildtrees.py
index 13d21548e..31af8a0e4 100644
--- a/tests/integration/shellbuildtrees.py
+++ b/tests/integration/shellbuildtrees.py
@@ -71,8 +71,8 @@ def test_buildtree_staged_warn_empty_cached(cli_integration, tmpdir, datafiles):
res = cli_integration.run(project=project, args=[
'shell', '--build', '--use-buildtree', 'always', element_name, '--', 'cat', 'test'
])
- res.assert_shell_error()
- assert "Artifact contains an empty buildtree" in res.stderr
+ res.assert_main_error(ErrorDomain.APP, None)
+ assert "Artifact was created without buildtree" in res.stderr
@pytest.mark.datafiles(DATA_DIR)
@@ -148,8 +148,8 @@ def test_buildtree_from_failure_option_never(cli_integration, tmpdir, datafiles)
res = cli_integration.run(project=project, args=[
'shell', '--build', element_name, '--use-buildtree', 'always', '--', 'cat', 'test'
])
- res.assert_shell_error()
- assert "Artifact contains an empty buildtree" in res.stderr
+ res.assert_main_error(ErrorDomain.APP, None)
+ assert "Artifact was created without buildtree" in res.stderr
@pytest.mark.datafiles(DATA_DIR)