summaryrefslogtreecommitdiff
path: root/tests/frontend/overlaps.py
diff options
context:
space:
mode:
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