[Notes] [Git][BuildStream/buildstream][tristan/fix-overlap-subproject-policy] tests/frontend/overlaps.py: Added regression test for cross project overlaps



Title: GitLab

Tristan Van Berkom pushed to branch tristan/fix-overlap-subproject-policy at BuildStream / buildstream

Commits:

7 changed files:

Changes:

  • tests/frontend/overlaps.py
    ... ... @@ -4,6 +4,7 @@ from buildstream.plugintestutils.runcli import cli
    4 4
     from buildstream._exceptions import ErrorDomain
    
    5 5
     from buildstream import _yaml
    
    6 6
     from buildstream.plugin import CoreWarnings
    
    7
    +from tests.testutils import generate_junction
    
    7 8
     
    
    8 9
     # Project directory
    
    9 10
     DATA_DIR = os.path.join(
    
    ... ... @@ -11,14 +12,11 @@ DATA_DIR = os.path.join(
    11 12
         "overlaps"
    
    12 13
     )
    
    13 14
     
    
    14
    -project_template = {
    
    15
    -    "name": "test",
    
    16
    -    "element-path": "."
    
    17
    -}
    
    18 15
     
    
    19
    -
    
    20
    -def gen_project(project_dir, fail_on_overlap, use_fatal_warnings=True):
    
    21
    -    template = dict(project_template)
    
    16
    +def gen_project(project_dir, fail_on_overlap, use_fatal_warnings=True, project_name="test"):
    
    17
    +    template = {
    
    18
    +        "name": project_name
    
    19
    +    }
    
    22 20
         if use_fatal_warnings:
    
    23 21
             template["fatal-warnings"] = [CoreWarnings.OVERLAPS] if fail_on_overlap else []
    
    24 22
         else:
    
    ... ... @@ -89,3 +87,30 @@ def test_overlaps_script(cli, datafiles, use_fatal_warnings):
    89 87
         result = cli.run(project=project_dir, silent=True, args=[
    
    90 88
             'build', 'script.bst'])
    
    91 89
         result.assert_success()
    
    90
    +
    
    91
    +
    
    92
    +@pytest.mark.datafiles(DATA_DIR)
    
    93
    +@pytest.mark.parametrize("project_policy", [('fail'), ('warn')])
    
    94
    +@pytest.mark.parametrize("subproject_policy", [('fail'), ('warn')])
    
    95
    +def test_overlap_subproject(cli, tmpdir, datafiles, project_policy, subproject_policy):
    
    96
    +    project_dir = str(datafiles)
    
    97
    +    subproject_dir = os.path.join(project_dir, 'sub-project')
    
    98
    +    junction_path = os.path.join(project_dir, 'sub-project.bst')
    
    99
    +
    
    100
    +    gen_project(project_dir, bool(project_policy == 'fail'), project_name='test')
    
    101
    +    gen_project(subproject_dir, bool(subproject_policy == 'fail'), project_name='subtest')
    
    102
    +    generate_junction(tmpdir, subproject_dir, junction_path)
    
    103
    +
    
    104
    +    # Here we have a dependency chain where the project element
    
    105
    +    # always overlaps with the subproject element.
    
    106
    +    #
    
    107
    +    # Test that overlap error vs warning policy for this overlap
    
    108
    +    # is always controlled by the project and not the subproject.
    
    109
    +    #
    
    110
    +    result = cli.run(project=project_dir, silent=True, args=['build', 'sub-collect.bst'])
    
    111
    +    if project_policy == 'fail':
    
    112
    +        result.assert_main_error(ErrorDomain.STREAM, None)
    
    113
    +        result.assert_task_error(ErrorDomain.PLUGIN, CoreWarnings.OVERLAPS)
    
    114
    +    else:
    
    115
    +        result.assert_success()
    
    116
    +        assert "WARNING [overlaps]" in result.stderr

  • tests/frontend/overlaps/sub-collect.bst
    1
    +kind: compose
    
    2
    +
    
    3
    +depends:
    
    4
    +- filename: c.bst
    
    5
    +  type: build
    
    6
    +- filename: a-sub.bst
    
    7
    +  junction: sub-project.bst
    
    8
    +  type: build
    
    9
    +- filename: z-sub.bst
    
    10
    +  junction: sub-project.bst
    
    11
    +  type: build

  • tests/frontend/overlaps/sub-project/a-sub.bst
    1
    +kind: import
    
    2
    +config:
    
    3
    +  source: /
    
    4
    +  target: /
    
    5
    +sources:
    
    6
    +- kind: local
    
    7
    +  path: "files/a"

  • tests/frontend/overlaps/sub-project/files/a/file3
    1
    +barny

  • tests/frontend/overlaps/sub-project/files/z/file1
    1
    +foo

  • tests/frontend/overlaps/sub-project/files/z/file2
    1
    +bar

  • tests/frontend/overlaps/sub-project/z-sub.bst
    1
    +kind: import
    
    2
    +config:
    
    3
    +  source: /
    
    4
    +  target: /
    
    5
    +sources:
    
    6
    +- kind: local
    
    7
    +  path: "files/z"



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]