[Notes] [Git][BuildStream/buildstream][doraskayo/filter-indirect-deps-fix] filter.py: don't recurse when staging dependencies



Title: GitLab

Dor Askayo pushed to branch doraskayo/filter-indirect-deps-fix at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • buildstream/plugins/elements/filter.py
    ... ... @@ -47,6 +47,8 @@ from buildstream import Element, ElementError, Scope
    47 47
     class FilterElement(Element):
    
    48 48
         # pylint: disable=attribute-defined-outside-init
    
    49 49
     
    
    50
    +    BST_ARTIFACT_VERSION = 1
    
    51
    +
    
    50 52
         # The filter element's output is its dependencies, so
    
    51 53
         # we must rebuild if the dependencies change even when
    
    52 54
         # not in strict build plans.
    
    ... ... @@ -102,7 +104,7 @@ class FilterElement(Element):
    102 104
     
    
    103 105
         def assemble(self, sandbox):
    
    104 106
             with self.timed_activity("Staging artifact", silent_nested=True):
    
    105
    -            for dep in self.dependencies(Scope.BUILD):
    
    107
    +            for dep in self.dependencies(Scope.BUILD, recurse=False):
    
    106 108
                     dep.stage_artifact(sandbox, include=self.include,
    
    107 109
                                        exclude=self.exclude, orphans=self.include_orphans)
    
    108 110
             return ""
    

  • tests/elements/filter.py
    ... ... @@ -464,3 +464,23 @@ def test_filter_track_multi_exclude(datafiles, cli, tmpdir):
    464 464
         assert "ref" not in new_input["sources"][0]
    
    465 465
         new_input2 = _yaml.load(input2_file)
    
    466 466
         assert new_input2["sources"][0]["ref"] == ref
    
    467
    +
    
    468
    +
    
    469
    +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
    
    470
    +def test_filter_include_with_indirect_deps(datafiles, cli, tmpdir):
    
    471
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    472
    +    result = cli.run(project=project, args=[
    
    473
    +        'build', 'output-include-with-indirect-deps.bst'])
    
    474
    +    result.assert_success()
    
    475
    +
    
    476
    +    checkout = os.path.join(tmpdir.dirname, tmpdir.basename, 'checkout')
    
    477
    +    result = cli.run(project=project, args=[
    
    478
    +        'artifact', 'checkout', 'output-include-with-indirect-deps.bst', '--directory', checkout])
    
    479
    +    result.assert_success()
    
    480
    +
    
    481
    +    # direct dependencies should be staged and filtered
    
    482
    +    assert os.path.exists(os.path.join(checkout, "baz"))
    
    483
    +
    
    484
    +    # indirect dependencies shouldn't be staged and filtered
    
    485
    +    assert not os.path.exists(os.path.join(checkout, "foo"))
    
    486
    +    assert not os.path.exists(os.path.join(checkout, "bar"))

  • tests/elements/filter/basic/elements/input-with-deps.bst
    1
    +kind: import
    
    2
    +
    
    3
    +depends:
    
    4
    +- filename: input.bst
    
    5
    +
    
    6
    +sources:
    
    7
    +- kind: local
    
    8
    +  path: files
    
    9
    +
    
    10
    +public:
    
    11
    +  bst:
    
    12
    +    split-rules:
    
    13
    +      baz:
    
    14
    +      - /baz

  • tests/elements/filter/basic/elements/output-include-with-indirect-deps.bst
    1
    +kind: filter
    
    2
    +
    
    3
    +depends:
    
    4
    +- filename: input-with-deps.bst
    
    5
    +  type: build



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