summaryrefslogtreecommitdiff
path: root/tests/frontend/overlaps.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-02-22 17:15:09 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-02-22 17:44:41 +0900
commitad5264418049b9c18f2030b92e25e331771716dc (patch)
tree89cda6890943eec6f4c00a60548133dde82223d9 /tests/frontend/overlaps.py
parenteb24011ff0b89ab1810357c6545f02e6cb3d7dfb (diff)
downloadbuildstream-ad5264418049b9c18f2030b92e25e331771716dc.tar.gz
tests/frontend/overlaps.py: Added regression test for cross project overlaps
This test ensures the overlap failure vs warning policy in one project only ever affects the artifacts created for the project which declares it and does not force it's policy onto another consuming project. A regression test against issue #926
Diffstat (limited to 'tests/frontend/overlaps.py')
-rw-r--r--tests/frontend/overlaps.py41
1 files changed, 33 insertions, 8 deletions
diff --git a/tests/frontend/overlaps.py b/tests/frontend/overlaps.py
index 36e15acd7..7c86445f6 100644
--- a/tests/frontend/overlaps.py
+++ b/tests/frontend/overlaps.py
@@ -1,6 +1,7 @@
import os
import pytest
from tests.testutils.runcli import cli
+from tests.testutils import generate_junction
from buildstream._exceptions import ErrorDomain
from buildstream import _yaml
@@ -10,15 +11,12 @@ DATA_DIR = os.path.join(
"overlaps"
)
-project_template = {
- "name": "test",
- "element-path": "."
-}
-
-def gen_project(project_dir, fail_on_overlap):
- template = dict(project_template)
- template["fail-on-overlap"] = fail_on_overlap
+def gen_project(project_dir, fail_on_overlap, project_name="test"):
+ template = {
+ "name": project_name,
+ "fail-on-overlap": fail_on_overlap
+ }
projectfile = os.path.join(project_dir, "project.conf")
_yaml.dump(template, projectfile)
@@ -82,3 +80,30 @@ def test_overlaps_script(cli, datafiles):
result = cli.run(project=project_dir, silent=True, args=[
'build', 'script.bst'])
result.assert_success()
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("project_policy", [('fail'), ('warn')])
+@pytest.mark.parametrize("subproject_policy", [('fail'), ('warn')])
+def test_overlap_subproject(cli, tmpdir, datafiles, project_policy, subproject_policy):
+ project_dir = str(datafiles)
+ subproject_dir = os.path.join(project_dir, 'sub-project')
+ junction_path = os.path.join(project_dir, 'sub-project.bst')
+
+ gen_project(project_dir, bool(project_policy == 'fail'), project_name='test')
+ gen_project(subproject_dir, bool(subproject_policy == 'fail'), project_name='subtest')
+ generate_junction(tmpdir, subproject_dir, junction_path)
+
+ # Here we have a dependency chain where the project element
+ # always overlaps with the subproject element.
+ #
+ # Test that overlap error vs warning policy for this overlap
+ # is always controlled by the project and not the subproject.
+ #
+ result = cli.run(project=project_dir, silent=True, args=['build', 'sub-collect.bst'])
+ if project_policy == 'fail':
+ result.assert_main_error(ErrorDomain.STREAM, None)
+ result.assert_task_error(ErrorDomain.ELEMENT, "overlap-error")
+ else:
+ result.assert_success()
+ assert "WARNING Non-whitelisted overlaps detected" in result.stderr